<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack" %>

<%@ page import="com.scalar.chiptrack.utils.ConfigManager,
                 com.scalar.chiptrack.commons.Constants,
                 com.scalar.chiptrack.sales.forms.SalesOrderForm,com.scalar.chiptrack.utils.StringUtils,
                 com.scalar.chiptrack.sales.CustomerPartNumber,
                 java.util.ArrayList,
                 org.apache.struts.util.LabelValueBean,
                 java.util.HashMap,
                 com.scalar.chiptrack.sales.ContactPerson,
                 com.scalar.chiptrack.sales.actions.ChangeOrderAction,
                 com.scalar.chiptrack.sales.SalesOrder,
                 com.scalar.chiptrack.sales.dao.CustomerRelationshipDAO"%>
<%@ page import="com.scalar.chiptrack.users.User"%>
<%@ page import="com.scalar.chiptrack.users.Functionality"%>
<%@ page import="com.scalar.chiptrack.sales.LineItem" %>
<%
    String chipTracContext = "/" + ConfigManager.getChipTracContext();
    int i = 0;
    int oldCount =0; // Variable used to compare the size of Previous Line items with Present line items.
    int noOfRows =0;
    String selectedMethod = null;
    String selectedAccount = null;
    com.scalar.chiptrack.sales.forms.SalesOrderForm salesOrderForm1 = null;
    String noOfDecimalsInAmount = ConfigManager.getnoOfDecmalsInAmount()+"";
    String restrictCharsJSFnc = "restrictCharacters(this,7,"+noOfDecimalsInAmount+")";
    String restrictAmtJSFnc = "restrictAmt(this,7,"+noOfDecimalsInAmount+")";
%>

<HTML>
<HEAD><TITLE>Scalarsoft - ChipTrac</TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<LINK href="<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css" type=text/css rel=stylesheet>
<script src="<%=chipTracContext%>/jsp/includes/scripts/functions.js"></script>
<script language="JavaScript" src="<%=chipTracContext%>/jsp/includes/scripts/validations.js"></script>
<script language="JavaScript" src="<%=chipTracContext%>/jsp/includes/scripts/change_sales_order.js"></script>
<SCRIPT language="JavaScript" src="<%=chipTracContext%>/jsp/includes/scripts/Product.js"></script>
<SCRIPT language="JavaScript" src="<%=chipTracContext%>/jsp/includes/scripts/sales_common.js"></script>
<script src="<%=chipTracContext%>/jsp/includes/scripts/quickSearch.js"></script>
<META content="MSHTML 5.50.4807.2300" name=GENERATOR></HEAD>
<BODY bgColor="#ffffff" leftMargin=0 topMargin=0 marginheight="0" marginwidth="0" onload='check();init();'>
<script language="JavaScript">
function init()
{
    if ( document.salesOrderForm["manufacturingPartNo"] != null )
    {
        var partNo = document.salesOrderForm["manufacturingPartNo"];
        var x = eval(document.salesOrderForm["manufacturingPartNo"]);
        if (x.name == 'manufacturingPartNo')
        {
            qs_1 = new QuickSearch(partNo, document.salesOrderForm["qs1"], false);  
        }
        else
        {
            for(var i=0; i < partNo.length; i++)
            {
                var tmp = 'qs_'+(i+1)+' = new QuickSearch(partNo['+i+'], document.salesOrderForm["qs'+(i+1)+'"], false)';
                eval(tmp);
            }
        }
    }
}
var isSample = 1;
var prevPrice = 0;
<%
    HashMap  salesOrderMap = ( HashMap ) session.getAttribute( "salesOrderMap" );
    SalesOrder salesOrderFromMap = null;
    if ( salesOrderMap != null )
    {
        salesOrderForm1 = ( SalesOrderForm ) request.getAttribute("salesOrderForm");
        salesOrderFromMap = ( SalesOrder ) salesOrderMap.get( salesOrderForm1.getCustomerId()+"" );
        if( salesOrderFromMap != null )
        {
            pageContext.setAttribute ( "billingAddressContactPersons", salesOrderFromMap.getContactPersonsForBillingAddress() );
            pageContext.setAttribute ( "shippingAddressContactPersons", salesOrderFromMap.getContactPersonsForShippingAddress() );
            pageContext.setAttribute ( "shippingAddresses", salesOrderFromMap.getShippingAddresses () );
            pageContext.setAttribute ( "billingAddresses", salesOrderFromMap.getBillingAddresses () );
            pageContext.setAttribute ( "contactPersons", salesOrderFromMap.getContactPersons () );
            pageContext.setAttribute ( "salesPersons", salesOrderFromMap.getSalesPersons() );
            pageContext.setAttribute ( "salesReps", salesOrderFromMap.getSalesReps() );
            pageContext.setAttribute ( "odmList", CustomerRelationshipDAO.getOdmsForChangeSalesOrder( salesOrderFromMap.getCustomerId()+"" , salesOrderFromMap.getOdmId()+"" ));
            pageContext.setAttribute( "endCustomerList", salesOrderFromMap.getEndCustomerList() );
            ArrayList lineItemsList = (ArrayList) request.getAttribute ( "presentLineItems" );
            if ( lineItemsList == null )
            { lineItemsList = (ArrayList) session.getAttribute ( "presentLineItems" );}
            ArrayList customerPartNumbers = new ArrayList();
            try{
               java.util.HashMap mapCustPartNos = salesOrderFromMap.getMfgPartsWithCustomerPartNos() ;
               for (int j = 0; j < lineItemsList.size(); j++) {
                    LineItem lineItem = (LineItem) lineItemsList.get(j);
                    if ( lineItem.getManufacturingPartNo() != null && lineItem.getManufacturingPartNo().trim().length() > 0)
                    {
                        customerPartNumbers = (ArrayList)mapCustPartNos.get(lineItem.getManufacturingPartNo());
                    }
                    request.setAttribute( "customerPartNumbers"+lineItem.getLineItemNo(),  customerPartNumbers);
               }
            }
            catch(Exception ex) {
                ex.printStackTrace();
            }
        }
    }
    HashMap contactPersonsList = salesOrderFromMap.getCustomerContactPersonMap();
    if( contactPersonsList != null)
    {
        int listSize = contactPersonsList.size();
        java.util.Iterator contactPersonsIterator = contactPersonsList.keySet().iterator();
        ContactPerson contactPersons[] = new ContactPerson[listSize];
        %>
        var customerContactPerson = new Array(<%=listSize%>);
        var customerPhNo          = new Array(<%=listSize%>);
        var customerCellNo        = new Array(<%=listSize%>);
        var customerFax           = new Array(<%=listSize%>);
        var customerEmail         = new Array(<%=listSize%>);
        customerContactPerson[-3] = '';
        customerContactPerson[-2] = -1;
        customerContactPerson[-1] = '';
        <%
        for( int aa = 0; aa < listSize ; aa++ )
        {
           Object key = (String)contactPersonsIterator.next();
           if( contactPersonsList.get(key)!= null )
            {
                if(contactPersonsList.containsKey(key))
                {
                    contactPersons[aa] = (ContactPerson)contactPersonsList.get(key);
                %>
                customerContactPerson[<%=aa%>] = '<%=contactPersons[aa].getContactPerson().replaceAll("'","\\\\" + "'")%>';
                customerPhNo[<%=aa%>]          = '<%=contactPersons[aa].getPhoneNumber().replaceAll("'","\\\\" + "'")%>';
                customerCellNo[<%=aa%>]        = '<%=contactPersons[aa].getCellNumber().replaceAll("'","\\\\" + "'")%>';
                customerFax[<%=aa%>]           = '<%=contactPersons[aa].getFaxNumber().replaceAll("'","\\\\" + "'")%>';
                customerEmail[<%=aa%>]         = '<%=contactPersons[aa].getEmail()%>';
                <%
               }
           }
       } //for
   }
    HashMap billAddressList = salesOrderFromMap.getBillingAddressMap();
    if( billAddressList != null )
    {
        int billListSize = billAddressList.size();
        java.util.Iterator billContactPersonsIterator = billAddressList.keySet().iterator();
        String billAddresses[] = new String[billListSize];
        %>
            var billContactPerson = new Array(<%=billListSize%>);
            var billAddress       = new Array(<%=billListSize%>);
            billContactPerson[-3] = '';
            billContactPerson[-2] = -1;
            billContactPerson[-1] = '';
        <%
        for( int bb = 0; bb < billListSize ; bb++)
        {
           Object key = (String)billContactPersonsIterator.next();
           if( billAddressList.get(key)!= null )
            {
                if(billAddressList.containsKey(key))
                {
                    billAddresses[bb] = (String)billAddressList.get(key);
                    %>
                    billContactPerson[<%=bb%>] = '<%=key.toString().replaceAll("'","\\\\" + "'")%>';
                    billAddress[<%=bb%>]       = '<%=(billAddresses[bb].toString()).replace('\n','~').replaceAll("'","\\\\" + "'")%>';
                    <%
               }
           }
       } //for
   }

    HashMap shipAddressList = salesOrderFromMap.getShippingAddressMap();
    if( shipAddressList != null )
    {
        int shipListSize = shipAddressList.size();
        java.util.Iterator shipContactPersonsIterator = shipAddressList.keySet().iterator();
        String shipAddresses[] = new String[shipListSize];
        %>
            var shipContactPerson = new Array(<%=shipListSize%>);
            var shipAddress       = new Array(<%=shipListSize%>);
            shipContactPerson[-3] = '';
            shipContactPerson[-2] = -1;
            shipContactPerson[-1] = '';
        <%
        for( int bb = 0; bb < shipListSize ; bb++)
        {
           Object key = (String)shipContactPersonsIterator.next();
           if( shipAddressList.get(key)!= null )
            {
                if(shipAddressList.containsKey(key))
                {
                    shipAddresses[bb] = (String)shipAddressList.get(key);
                    %>
                    shipContactPerson[<%=bb%>] = '<%=key.toString().replaceAll("'","\\\\" + "'")%>';
                    shipAddress[<%=bb%>]       = '<%=(shipAddresses[bb].toString()).replace('\n','~').replaceAll("'","\\\\" + "'")%>';
                    <%
               }
           }
       } //for
   }
%>
//For Forming Shipping Methods Array.
<%
    ArrayList shipArr = (ArrayList)request.getAttribute("shippingMethods");
    int size1 =0;
	if(shipArr !=  null)
    {
		size1 = shipArr.size();
    }
%>
    var shppingLables = new Array(<%=size1%>);
    var shppingValues = new Array(<%=size1%>);
<%
	if( shipArr != null)
    {
%>
		shppingLables[-2] = '';
		shppingLables[-1] = '';
<%
		for(int s = 0 ; s < shipArr.size() ; s++)
		{
%>
		shppingLables[<%=s%>] = '<%=((org.apache.struts.util.LabelValueBean)shipArr.get(s)).getLabel().replaceAll("'","\\\\" + "'")%>';
        shppingValues[<%=s%>] ='<%=((org.apache.struts.util.LabelValueBean)shipArr.get(s)).getValue().replaceAll("'","\\\\" + "'")%>';
<%		}	%>
		shppingLables[<%=size1%>] = -2 ;
<%  }		%>

function contactPersonss( contactPersonName, phNo, cellNo, fax, email )
{
	this.contactPersonName = contactPersonName;
	this.phNo = phNo;
	this.cellNo = cellNo;
	this.fax = fax;
	this.email = email;
}

if (document.layers)
{
	window.setResizable(false);
}
var count = <%= (String)session.getAttribute("maxLineItemNo") %>
var errors = "";
var index  = 0;


var dateElement = "";
function openCalendar(dateValue)
{
	dateElement = dateValue;
	newWindow = window.open('<%=chipTracContext%>/jsp/includes/calendar.html','calenderPopup','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=no,width=180,height=440,resizable=no');
	newWindow.moveTo(550,180);
	newWindow.focus();
}

function assignDate(passedValue)
{
	dateElement.value=passedValue;
	window.focus();
}

    function check()
	{
		var pa1=document.getElementById("newshippingMethod");
		var pa3=document.getElementById("newshippingAccount");
		isSample = <%=request.getParameter("isSample")%>

		document.salesOrderForm.shippingAddressId.value=<%=salesOrderForm1.getShippingAddressId()%>;
		document.salesOrderForm.billingAddressId.value=<%=salesOrderForm1.getBillingAddressId()%>;
		<%
			String addShipMethod = request.getParameter("shipAccount1");
            if(addShipMethod==null || (!addShipMethod.equals("-2")))
            {
		%>
				document.salesOrderForm.newshippingMethod.style.visibility = "hidden";
				pa1.innerHTML = "";
				document.salesOrderForm.newshippingAccount.style.visibility = "hidden";
				pa3.innerHTML = "";
		<%
			}
            if((addShipMethod!=null) && (!addShipMethod.trim().equals("")))
            {
		%>
				document.salesOrderForm.shippingMethod.value = '<%=addShipMethod%>'
				document.salesOrderForm.shipAccount1.value = '<%=addShipMethod%>';
				if ( document.salesOrderForm.shippingMethod.value == "" )
				{
					document.salesOrderForm.shippingMethod.value = "-1";
				}
		<%
			}
        %>
		var salesTaxType = document.salesOrderForm.salesTaxType.value;
		<%
			String state1 = salesOrderForm1.getNewSalesState();
			String value1 = salesOrderForm1.getNewSalesTax();
			if( state1 != null && value1 != null )
			{
		%>
				if ( salesTaxType == "-1" )
                {
					addNewSalesTaxType( document.salesOrderForm.salesTaxType );
                    document.salesOrderForm.newSalesState.value = '<%=state1%>';
                    document.salesOrderForm.newSalesTax.value = '<%=value1%>';
				}
         <%	} %>
		var shippingLabel		= document.getElementById("newShippingTerms");
		var letterOfCreditNoObj = document.getElementById("letterOfCreditNo");
		var lcIssuingBankObj    = document.getElementById("lcIssuingBank");
		var deliveryTermsLabel	= document.getElementById("newDeliveryTerms");
		var pa = document.getElementById("shippingInstructions");

		if( document.salesOrderForm.shippingTerms.value == -2 )
		{
			document.salesOrderForm.newShippingTerms.style.visibility = "visible";
			shippingLabel.innerHTML = "New Pay Terms : ";
		}
		else
		{
			document.salesOrderForm.newShippingTerms.style.visibility = "hidden";
			shippingLabel.innerHTML = "";
		}

		if( document.salesOrderForm.deliveryTerms.value == -2 )
		{
			document.salesOrderForm.newDeliveryTerms.style.visibility = "visible";
			deliveryTermsLabel.innerHTML = "New <bean:message key="label.sales.salesOrder.DeliveryTerms" /> : ";
		}
		else
		{
			document.salesOrderForm.newDeliveryTerms.style.visibility = "hidden";
			deliveryTermsLabel.innerHTML = "";
		}

        if ( document.salesOrderForm.shippingInstructionsId.value == -2 )
        {
            pa.innerHTML = "New <bean:message key="label.sales.shippingInstructions" />"
            document.salesOrderForm.shippingInstructions.readOnly = false;
        }
        else
        {
            pa.innerHTML = "<bean:message key="label.sales.shippingInstructions" />"
            document.salesOrderForm.shippingInstructions.readOnly = true;
        }

        if(document.salesOrderForm.contactPerson.value == document.salesOrderForm.customerName.value )
        {
            document.salesOrderForm.cellNumber.disabled = true;
        }

        if( document.salesOrderForm.contactPerson.value == '' )
        {
            document.salesOrderForm.contactPerson.value = '';
            document.salesOrderForm.phoneNumber.value = '';
            document.salesOrderForm.cellNumber.value = '';
            document.salesOrderForm.faxNumber.value = '';
            document.salesOrderForm.email.value = '';

            document.salesOrderForm.phoneNumber.disabled = true;
            document.salesOrderForm.cellNumber.disabled = true;
            document.salesOrderForm.faxNumber.disabled = true;
			document.salesOrderForm.email.disabled = true;
        }
        if ( isSample == 0 )
        {
            var price = document.salesOrderForm["unitPriceAsDouble"];
            var lineitem = eval(document.salesOrderForm["lineItemNo"]);
            if( lineitem.name == 'lineItemNo' )
			{
                var element2 = eval( "document.salesOrderForm.expediteFee"+( document.salesOrderForm.lineItemNo.value - 1 ));
                if( element2 != 'undefined')
				{
					element2.disabled = true;
				}
            }
            else
			{
                for( var i = 0; i < lineitem.length; i++ )
				{
                    var element2 = eval("document.salesOrderForm.expediteFee"+(document.salesOrderForm.lineItemNo[i].value - 1 ) );
                    if( element2 != 'undefined')
					{
						element2.disabled = true;
					}
                }
            }
        }
        showHideNewEndUserField();
        var form = document.salesOrderForm;
        var endCustomerCtrl = form.odmId;
        var newEndCustomerNameCtrl = form.newEndCustomerName;
        var endCustomerLabelSpan = document.getElementById ( "endCustomerLabelSpan" );
        var endCustomerTxfieldSpan = document.getElementById ( "endCustomerTxfieldSpan" );
        if ( endCustomerCtrl.value == "-2" )
        {
            endCustomerLabelSpan.style.display = 'block'
            endCustomerTxfieldSpan.style.display = 'block'
        }
        else
        {
            newEndCustomerNameCtrl.value = "";
            endCustomerLabelSpan.style.display = 'none'
            endCustomerTxfieldSpan.style.display = 'none'
        }
        showHideNewCustPartNo(-1);
    }

    function addTextArea()
	{
		index = document.salesOrderForm.requestDate.length;
        if ( index == null )
        {
            index = 1;
        }
        var tab = document.getElementById( "lineItemsTable" );
        var newRowIndex = document.getElementById( "rowIndex" ).rowIndex;
        var newRow = tab.insertRow( newRowIndex );
        var newCell = newRow.insertCell();
        newCell.style.backgroundColor = "#DEE1E2";
        var htmltext = '<input type="text" name="lineItemNo" value="'+count+'" size=6 class="txfield" disabled="true">';
        htmltext = htmltext + ' <input type="hidden" name="scheduleDate" value="">';
        htmltext = htmltext + '<input type="hidden" name="revisedDate" value="">';
        newCell.innerHTML = htmltext;

        newCell = newRow.insertCell ();
        newCell.style.backgroundColor = "#DEE1E2";
        htmltext = '<input type="text" name="poLineItemNo" size=6 class="txfield">';
        htmltext = htmltext + '<input type="hidden" name="statusq" value="PENDING">';
        htmltext = htmltext + '<input type="hidden" name="oldstatusq" value="PENDING">';
        htmltext = htmltext + '<input type="hidden" name="finalStatus" value="PENDING">';

        htmltext = htmltext + '<input type="hidden" name="isNewLineItem" value="true">';
        newCell.innerHTML = htmltext;

        newCell = newRow.insertCell ();
        newCell.style.backgroundColor = "#DEE1E2";
        htmltext = '&nbsp;<script language="javascript" defer="defer"> qs_'+count+' = new QuickSearch(document.salesOrderForm.manufacturingPartNo['+(count-1)+'],  document.salesOrderForm["qs'+count+'"], false );<'+'/'+'script>';
        htmltext = htmltext +'<input type="text" name="qs'+count+'" class="txfield" size="35" onkeyup="quickSearch(qs_'+count+')"/><br>';
        htmltext = htmltext +'<select name="manufacturingPartNo" class="txfield" onchange="getComments('+rowCount+');';
        <% if(ConfigManager.getBooleanProperty(ConfigManager.PROP_SHOW_SALES_LINEITEM_MARKETING_PART_NUMBER)) { %>
            htmltext= htmltext +'showMktgPartNumber('+rowCount+');';
        <% } %>
        htmltext= htmltext + '"><option value="" >Select Part Number</option>';
        <%
			java.util.ArrayList optionlist	= null;
            java.util.ArrayList mfgList		= null;
            org.apache.struts.util.LabelValueBean option = null;
            CustomerPartNumber customerPartNo = new  CustomerPartNumber();
            StringBuffer strBuffer	= null;
            StringBuffer strBuffer1 = null;
            int mfgListsize =0;
			try
			{
				mfgList = salesOrderFromMap.getMfgParts();
				if( mfgList == null)  mfgList =  new java.util.ArrayList();
				mfgListsize = mfgList.size();
				strBuffer1 = new StringBuffer();
				for( int j = 0; j < mfgListsize; j++)
				{
					customerPartNo = (CustomerPartNumber)mfgList.get(j);
					strBuffer1.append("htmltext = htmltext + '");
					strBuffer1.append("<option value=\"").append(customerPartNo.getManufacturingPartNo()).append("\">");
					strBuffer1.append(customerPartNo.getManufacturingPartNo()).append("</option>';\n");
				}
				out.println(strBuffer1);
            }
            catch(Exception ex)
            {
            	System.out.println(ex);
            }
        %>
        htmltext = htmltext + '</select></td>';
		newCell.innerHTML = htmltext;

        <% if(ConfigManager.getBooleanProperty(ConfigManager.PROP_SHOW_SALES_LINEITEM_MARKETING_PART_NUMBER)) { %>
            newCell = newRow.insertCell ();
            newCell.style.backgroundColor = "#DEE1E2";
            htmltext = '<span class="NArialL" id="marketingPartNoSpan'+rowCount+'"></span>';
            newCell.innerHTML = htmltext;
         <% } %>

        newCell = newRow.insertCell ();
        newCell.style.backgroundColor = "#DEE1E2";
        htmltext = '<select name="customerPartNo"  class="txfield" onchange="showHideNewCustPartNo(' + rowCount + ')"><option value="">Select Customer Part No</option><option value="-2">--Add New CustomerPart No--</option></select><input type="text" name="newCustomerPartNo" maxlength="50" size="20" value="" style="display:none;" class="txfield">';
        newCell.innerHTML = htmltext;
        newCell = newRow.insertCell ();
        newCell.style.backgroundColor = "#DEE1E2";
        htmltext = '<textarea name="lineItemDescription" class="txfield" onkeydown="javascript:setTextAreaMaxLength(this,200)" onkeyup="javascript:setTextAreaMaxLength(this,200)"></textarea>';
        newCell.innerHTML = htmltext;

        newCell = newRow.insertCell ();
        newCell.style.backgroundColor = "#DEE1E2";
        newCell.style.textAlign = "center";
        <% if((request.getParameter("isSample") != null) && (request.getParameter("isSample").equals("0"))) { %>
            htmltext = '<input type=checkbox name="isTaxable'+count+'" disabled="true">';
        <% } else { %>
            htmltext = '<input type=checkbox name="isTaxable'+count+'" >';
        <% }%>
        newCell.innerHTML = htmltext;

        newCell = newRow.insertCell ();
        newCell.style.backgroundColor = "#DEE1E2";
        newCell.noWrap = true;
        htmltext = '<input type="text" name="requestDate" size=15 class="txfield">';
        htmltext = htmltext + '&nbsp;<a href="javascript:openCalendar(document.salesOrderForm.requestDate['+index+'])"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/date_selector.gif" height=20 width=20></img></a>';
        newCell.innerHTML = htmltext;

        newCell = newRow.insertCell ();
        newCell.style.backgroundColor = "#DEE1E2";
        htmltext = '<input type="text" name="quantity" size=8 class="valuetxfield" value="0" onkeypress="javascript:allowInteger()" onblur="checkBaseOrderQty('+ rowCount +')" maxlength="6" >';
        htmltext = htmltext + '<input type="hidden" name="oldQty" value="0">';
        newCell.innerHTML = htmltext;

        newCell = newRow.insertCell ();
        newCell.style.backgroundColor = "#DEE1E2";
        if ( isSample == 0 )
        {
            htmltext = '<input type="text" name="unitPriceAsDouble" size=13 class="valuetxfield" value="0.0" maxlength="9" onkeypress="javascript:restrictCharacters(this,7,<%=ConfigManager.getnoOfDecmalsInAmount()%>)" onkeyup="javascript:restrictAmt(this,7,<%=ConfigManager.getnoOfDecmalsInAmount()%>)">';
        }
        else
        {
            htmltext = '<input type="text" name="unitPriceAsDouble" size=13 class="valuetxfield" value="0.0" maxlength="9" onkeypress="javascript:restrictCharacters(this,7,<%=ConfigManager.getnoOfDecmalsInAmount()%>)" onkeyup="javascript:restrictAmt(this,7,<%=ConfigManager.getnoOfDecmalsInAmount()%>)" >';
        }
        newCell.innerHTML = htmltext;

        newCell = newRow.insertCell ();
        newCell.style.backgroundColor = "#DEE1E2";
        htmltext = '<input type="text" name="amount" size=25 class="valuetxfield" value="$0.00" disabled="true">';
        newCell.innerHTML = htmltext;

        newCell = newRow.insertCell ();
        newCell.style.backgroundColor = "#DEE1E2";
        newCell.style.textAlign = "center";
        if ( isSample == 0 )
        {
            htmltext = '<input type=checkbox name="zeroPrice'+(count)+'" onClick="javascript:setZeroPrice('+( count-1 )+', '+count+')" <%=ConfigManager.isDefaultZeroPriceForSampleSO() ? "CHECKED" : ""%> >';
        }
        else
        {
            htmltext = '<input type=checkbox name="zeroPrice'+(count)+'" onClick="javascript:setZeroPrice('+( count-1 )+', '+count+')">';
        }
        htmltext = htmltext + '<input type="hidden" name="issueStatus" value="NOT ISSUED">';
        htmltext = htmltext + '<input type="hidden" name="cancelStatus" value="1">';
        newCell.innerHTML = htmltext;

        newCell = newRow.insertCell ();
        newCell.style.backgroundColor = "#DEE1E2";
        newCell.style.textAlign = "center";
        htmltext = '<input type="checkbox" name="cancel'+(count-1)+'" value="on" disabled="true" >';
        newCell.innerHTML = htmltext;

        newCell = newRow.insertCell ();
        newCell.style.backgroundColor = "#DEE1E2";
        newCell.style.textAlign = "center";
        if ( isSample == 0 )
        {
            htmltext = '<input type="checkbox" name="expediteFee'+(count-1)+'" value="on" disabled="true">';
        }
        else
        {
            htmltext = '<input type="checkbox" name="expediteFee'+(count-1)+'" value="on" >';
        }
        newCell.innerHTML = htmltext;

         <%
            if(ConfigManager.getBooleanProperty(ConfigManager.PROP_SHOW_SALES_LINEITEM_CUSTOM_PRICE_FIELD1)) {
         %>
            newCell = newRow.insertCell ();
            newCell.style.backgroundColor = "#DEE1E2";
            htmltext = '<input type="text" name="customPriceField1" size=13 class="valuetxfield" value="0.0" maxlength="9" onkeypress="javascript:restrictCharacters(this,7,<%=ConfigManager.getnoOfDecmalsInAmount()%>)" onkeyup="javascript:restrictAmt(this,7,<%=ConfigManager.getnoOfDecmalsInAmount()%>)" >';
            newCell.innerHTML = htmltext;
         <%
             }
             if(ConfigManager.getBooleanProperty(ConfigManager.PROP_SHOW_SALES_LINEITEM_CUSTOM_TEXT_FIELD1)) {
         %>
                newCell = newRow.insertCell ();
                newCell.style.backgroundColor = "#DEE1E2";
                htmltext = '<textarea name="customTextField1" class="txfield" onkeydown="javascript:setTextAreaMaxLength(this,200)" onkeyup="javascript:setTextAreaMaxLength(this,200)"></textarea>';
                newCell.innerHTML = htmltext;
         <%
             }
         %>
    	rowCount++;
        count++;
        noofrows++;
    }
function assignShippingInstructions(elementName)
{
	var shippingInstructions = document.getElementById("shippingInstructions");
	if (elementName.value == "-1")
	{
		shippingInstructions.innerHTML = "<bean:message key="label.sales.shippingInstructions" />"
		document.salesOrderForm.shippingInstructions.value = "";
		document.salesOrderForm.shippingInstructions.readOnly = true;
	}
	else if (elementName.value == "-2")
	{
		shippingInstructions.innerHTML = "New <bean:message key="label.sales.shippingInstructions" />"
		document.salesOrderForm.shippingInstructions.value = "";
		document.salesOrderForm.shippingInstructions.readOnly = false;
		document.salesOrderForm.shippingInstructions.focus();
	}
	else if (Number(elementName.value) > 0)
		{
			var customerpo = document.salesOrderForm["customerPO"];
			var qty = document.salesOrderForm["quantity"];
			var price = document.salesOrderForm["unitPriceAsDouble"];
			var partNo = document.salesOrderForm["manufacturingPartNo"];
			var frieght = document.salesOrderForm["frieghtAsDouble"];
			var misc = document.salesOrderForm["miscAsDouble"];
			var miscName = document.salesOrderForm["miscName"].value;
			var date = document.salesOrderForm["requestDate"];
			var x = eval(document.salesOrderForm["manufacturingPartNo"]);
			var isSample = document.salesOrderForm.isSample.value;


			if (x.name == 'manufacturingPartNo') {
				document.salesOrderForm.manufacturingPartNo.disabled = false;
			}
			else {
				for (var i = 0; i < x.length; i++) {
					x[i].disabled = false;
				}
			}
			var z = eval(document.salesOrderForm["quantity"]);
			if (z.name == 'quantity') {
				document.salesOrderForm.quantity.disabled = false;
			} else {
				for (var j = 0; j < z.length; j++)
				{
					z[j].disabled = false;
				}
			}

			var reqDt = eval(document.salesOrderForm["requestDate"]);
			if (reqDt.name == 'requestDate') {
				document.salesOrderForm.requestDate.disabled = false;
			}
			else {
				for (var j = 0; j < reqDt.length; j++) {
					reqDt[j].disabled = false;
				}
			}
			var pric = eval(document.salesOrderForm["unitPriceAsDouble"]);
			if (pric.name == 'unitPriceAsDouble') {
				document.salesOrderForm.unitPriceAsDouble.disabled = false;
			}
			else {
				for (var j = 0; j < pric.length; j++) {
					pric[j].disabled = false;
				}
			}

			for (var txble = 0; txble < count; txble++) {
				var isTaxabl = eval(document.salesOrderForm["isTaxable" + txble]);
				if ((isTaxabl != null) && (isTaxabl.disabled == true)) {
					if (isSample != 0)
					{
						isTaxabl.disabled = false;
					}
				}
			}
			var y = eval(document.salesOrderForm["lineItemDescription"]);
			if (y.name == 'lineItemDescription') {
				document.salesOrderForm.lineItemDescription.disabled = false;
			}
			else {
				for (var j = 0; j < y.length; j++) {
					y[j].disabled = false;
				}
			}
			var po_lineitem = eval(document.salesOrderForm["poLineItemNo"]);
			if (po_lineitem.name == 'poLineItemNo') {
				document.salesOrderForm.poLineItemNo.disabled = false;
			}
			else {
				for (var j = 0; j < po_lineitem.length; j++) {
					po_lineitem[j].disabled = false;
				}
			}
			var lineitem = eval(document.salesOrderForm["lineItemNo"]);
			if (lineitem.name == 'lineItemNo') {
				document.salesOrderForm.lineItemNo.disabled = false;
				(eval("document.salesOrderForm.zeroPrice" + (document.salesOrderForm.lineItemNo.value))).disabled = false;
			}
			else {
				for (var j = 0; j < lineitem.length; j++) {
					lineitem[j].disabled = false;
					(eval("document.salesOrderForm.zeroPrice" + (document.salesOrderForm.lineItemNo[j].value))).disabled = false;
				}
			}

			document.salesOrderForm.shippingAddress.disabled = false;
			document.salesOrderForm.billingAddress.disabled = false;
			document.salesOrderForm.phoneNumber.disabled = false;
			document.salesOrderForm.faxNumber.disabled = false;
			document.salesOrderForm.email.disabled = false;
			document.salesOrderForm.shippingAccount.disabled = false;
			document.salesOrderForm.contactPerson.disabled = false;

			for (var cancl = 0; cancl < count; cancl++) {
				var isCancelled = eval(document.salesOrderForm["cancel" + cancl]);
				if ((isCancelled != null) && (isCancelled.disabled == true)) {
					isCancelled.disabled = false;
				}
			}
			if (document.salesOrderForm.contactPerson.value == -1 || document.salesOrderForm.contactPerson.value == '')
			{
				document.salesOrderForm.phoneNumber.value = "";
				document.salesOrderForm.faxNumber.value = "";
				if (document.salesOrderForm.cellNumber != null)
				{
					document.salesOrderForm.cellNumber.value = "";
				}
				document.salesOrderForm.email.value = "";
			}

			enableCustPartNos();//function
			enablePrices();
			document.salesOrderForm.customerPO.disabled = false;
			document.salesOrderForm.shippingAddress.disabled = false;
			document.salesOrderForm.billingAddress.disabled = false;
			document.salesOrderForm.salesTaxType.disabled = false;
			document.salesOrderForm.miscAsDouble.disabled = false;
			document.salesOrderForm.frieghtAsDouble.disabled = false;
			document.salesOrderForm.salesOrderDate.disabled = false;
			document.salesOrderForm.action.value = "loadShippingInstructions";
			document.salesOrderForm.submit();
		}
}

function getEndCustomerShippingAddress(elementName)
{
	var endCustomerId = document.salesOrderForm["odmId"];
	var pa = document.getElementById("error");
	if (elementName.checked)
	{
		if (endCustomerId.value <= 0)
		{
			pa.innerHTML = '<li>Please select <bean:message key="label.sales.endCustomer"/></li>';
			elementName.checked = false;
			return;
		}
	}
	enableFormFields();
	document.salesOrderForm.action.value = "loadEndCustomerDefualtShippingAddress";
	document.salesOrderForm.submit();
}

    function submitPage(action)
    {

        errors = "";
		if( !dateValidation() )
		{
            errors = errors;
        }

        var customerpo = document.salesOrderForm["customerPO"];
        var qty = document.salesOrderForm["quantity"];
        var price = document.salesOrderForm["unitPriceAsDouble"];
        var partNo = document.salesOrderForm["manufacturingPartNo"];
		var frieght = document.salesOrderForm["frieghtAsDouble"];
	    var misc = document.salesOrderForm["miscAsDouble"];
        var salesPerson = document.salesOrderForm["salesPerson"];
		var miscName = document.salesOrderForm["miscName"].value;
        var email = document.salesOrderForm["email"];
		var date = document.salesOrderForm["requestDate"];
        var shippingInstructions = document.salesOrderForm["shippingInstructions"];
        var freightInstructions = document.salesOrderForm["freightInstructions"];

        document.salesOrderForm["customerPO"].disabled = false;
        document.salesOrderForm.salesOrderDate.disabled = false;

        //To elimenate the leadin and trail spaces for poLineItemNo,Quantity,Price, new Sales Tax,frieght,Misc
		removePrePostSpaces(document.salesOrderForm["poLineItemNo"]);
        removePrePostSpaces(qty);
        removePrePostSpaces(price);
        var isSample = document.salesOrderForm.isSample.value;


		if( email.value != '' )
		{
			if( !isValidEMailId ( email ) )
			{
				var pa = document.getElementById("error");
				pa.innerHTML = "<li> Please enter a valid email address";
				email.select();
				email.focus();
				return;
			}
		}

        if( document.salesOrderForm["shippingAddress"].value == '' )
        {
             var pa=document.getElementById("error");
             pa.innerHTML = "<li> Please enter shipping Address";
             return;
        }
		if( document.salesOrderForm.salesTaxType.value == -1)
		{
			removePrePostSpaces(document.salesOrderForm["newSalesTax"]);
		}
		removePrePostSpaces(frieght);
		removePrePostSpaces(misc);


		var error_status = eval(document.salesOrderForm["errorStatus"]);

		if(error_status.name == 'errorStatus')
		{
			if(document.salesOrderForm.errorStatus.value != '')
			{

				var pa = document.getElementById("errors");
				pa.innerHTML = "<li>&nbsp;"+document.salesOrderForm.errorStatus.value;
				return;
			}
		}
		else
		{
			for(var j=0; j< error_status.length; j++)
			{
				if(document.salesOrderForm.errorStatus[j].value != '')
				{
					//alert(document.salesOrderForm.errorStatus.value);
					var pa = document.getElementById("errors");
					pa.innerHTML = "<li>&nbsp;"+document.salesOrderForm.errorStatus[j].value;
					return;
				}
			}
		}
		if( document.salesOrderForm.poDate.value != '' && !validateBookingDate( document.salesOrderForm.poDate.value ) )
		{
			var pa=document.getElementById("error");
			pa.innerHTML = "<li> PO Date should be in 'mm/dd/yyyy' format ";
			location="#e1"
			return;
		}

		if( (!(is_Sp_Characters(customerpo.value)) ) || (check_char_position(customerpo.value))  )
		{
			var pa=document.getElementById("error");
			pa.innerHTML = "<li> Customer PO No: will accept alphanumeric and special characters -, _ only";
			location="#e1"
			return;
		}

		if( isSample == 1 )
		{
			if (customerpo.value.trim()=="")
			{
				var pa=document.getElementById("error");
				pa.innerHTML = "<li> Customer PO No cannot be blank";
				location="#e1"
			   return;
			}
		}

		if( document.salesOrderForm.salesOrderDate.value.trim() == "" )
		{
			var pa=document.getElementById("error");
			pa.innerHTML = "<li> Booking Date cannot be blank";
			location="#e1"
		   return;
		}
		else if( document.salesOrderForm.salesOrderDate.value !="")
		{
			if(!validateBookingDate(document.salesOrderForm.salesOrderDate.value))
			{
				var pa=document.getElementById("error");
				pa.innerHTML = "<li> Booking Date should be in 'mm/dd/yyyy' format ";
				location="#e1"
				return;
			}
		}
        <%
            if ( ConfigManager.isEndUserMandatory() )
            {
        %>
                if ( document.salesOrderForm.endCustomerId.value == '-1' || document.salesOrderForm.endCustomerId.value == '' )
                {
                    var pa=document.getElementById("error");
                    pa.innerHTML = '<li> Please select <bean:message key="label.sales.endUser"/>';
                    location="#e1"
                    return;
                }
                else if ( document.salesOrderForm.endCustomerId.value == '-2' && document.salesOrderForm.newEndUserName.value.trim() == '' )
                {
                    var pa=document.getElementById("error");
                    pa.innerHTML = '<li> Please enter new <bean:message key="label.sales.endUser"/>';
                    location="#e1"
                    return;
                }
        <%
            }
        %>
        <%
            if ( ConfigManager.isEndCustomerMandatory() )
            {
        %>
                if ( document.salesOrderForm.odmId.value == '-1' || document.salesOrderForm.odmId.value == '' )
                {
                    var pa=document.getElementById("error");
                    pa.innerHTML = '<li> Please select <bean:message key="label.sales.endCustomer"/>';
                    location="#e1"
                    return;
                }
                else if ( document.salesOrderForm.odmId.value == '-2' && document.salesOrderForm.newEndCustomerName.value.trim() == '' )
                {
                    var pa=document.getElementById("error");
                    pa.innerHTML = '<li> Please enter new <bean:message key="label.sales.endCustomer"/>';
                    location="#e1"
                    return;
                }
        <%
            }
        %>
        if( (text_area(shippingInstructions.value)) == true)
		{
			errors = errors + '<br>' + "<li>  ShippingInstructions should not exceed 300 characters";
		}
		if( (text_area(freightInstructions.value)) == true)
		{
			errors = errors + '<br>' + "<li>  FreightInstructions should not exceed 300 characters";
		}
		if( (text_area(freightInstructions.value)) == true)
		{
			errors = errors + '<br>' + "<li>  FreightInstructions should not exceed 300 characters";
		}


		if(document.salesOrderForm["quantity"].length == null)
        {
			if(partNo.value != '')
			{
				if(partNo.value == '---- BOARD -----' || partNo.value == '---- KIT -----' || partNo.value == '---- CHIPS -----')
				{
					errors = errors +'<br>' + "<li>  Please select the Part Number ";
				}
				if(qty.value != '')
				{
					if(!isInteger(qty.value))
					{
						errors = errors +'<br>' + "<li>  Please enter a valid quantity ";
						qty.select();
					}
					else if(qty.value == 0)
					{
						errors = errors +'<br>' + "<li>  Please enter a valid quantity ";
						qty.select();
					}
					else if((qty.value).length > 6)
					{
						errors = errors +'<br>' + "<li>  Please enter a valid quantity (should not allow more than 6 digits)";
						qty.select();
					}
				}
				else
				{
					errors = errors +'<br>' + "<li>  Please enter the quantity";
				}
			}
			else
			{
				    errors = errors +'<br>' + "<li>  Please select the Part Number ";
			}
        }
	    else
		{
             for( var i = 0; i < qty.length; i++ )
             {
                if( partNo[i].value != '')
				{
					if( partNo[i].value == '---- BOARD -----' || partNo[i].value == '---- KIT -----' || partNo[i].value == '---- CHIPS -----' )
					{
						errors = errors +'<br>' + "<li>  Please select the Part Number for Lineitem"+(i+1);
						break;
					}
					if ( qty[i].value != '')
					{
						 if( !isInteger(qty[i].value ) )
						 {
							errors = errors +'<br>' + "<li>  Please enter a valid quantity ";
							qty[i].select();
							break;
						  }
						  else if( qty[i].value == 0)
						  {
							errors = errors + '<br>' +"<li>  Please enter a valid quantity ";
							qty[i].select();
							break;
				    	  }
                         else if((qty[i].value).length > 6)
						 {
							errors = errors + '<br>' +"<li>  Please enter a valid quantity (should not allow more than 6 digits)";
							qty[i].select();
							break;
			         	 }
                    }
					else
					{
						 errors = errors +'<br>' + "<li>  Please enter the quantity";
						 qty[i].select();
						 break;
					}
		  }
          else if( (trim(qty[i].value).length != 1 && trim(qty[i].value) != 0 ) || (trim(date[i].value).length != 0) )
		  {

			if(partNo[i].value == '')
			{
				errors = errors +'<br>' + "<li>  Please select the Part Number for Lineitem"+(i+1);
				break;
			}
		 }
       }
	}

	if(document.salesOrderForm["unitPriceAsDouble"].length == null)
    {
		if(price.value != '')
		{
			var j = 0;
			for(var k = 0; k < (price.value).length; k++)
			{
				var c = (price.value).charAt(k);
				if( c == '.' )
				{
					j++;
					if(j > 1 )
					{
						errors = errors +'<br>' + "<li>  Please enter a valid price";
						price.select();
						break;
					}
				}
			}
			if(check_char_position4(price.value) || (is_Sp_Characters_frieght(price.value) == false) )
			{
				errors = errors +'<br>' + "<li>  Please enter a valid price";
				price.select();
			}
        }
        else
        {
	            errors = errors +'<br>' + "<li>  Please enter the price";
		}
	}
	else
    {
		for(var i=0; i< price.length; i++)
	    {
			if(partNo[i].value != '')
            {
				if (price[i].value != '')
				{
					var j = 0;
					for(var k = 0; k < (price[i].value).length;k++)
					{
						var c = (price[i].value).charAt(k);
						if( c == '.' )
						{
							j++;
							if(j > 1 )
							{
								errors = errors +'<br>' + "<li>  Please enter a valid price";
								price[i].select();
								break;
							}
						}
					}
					if(check_char_position4(price[i].value) || (is_Sp_Characters_frieght(price[i].value) == false) )
					{
						errors = errors +'<br>' + "<li>  Please enter a valid price";
						price[i].select();
						break;
					}

				}
				else
				{
					errors = errors +'<br>' + "<li>  Please enter the price";
					price[i].select();
					break;
				}
			}

	        if(partNo[0].value =='')
            {
				errors = "<li>  Please select the Part Number for Lineitem1";
	        }
		}
	}

	if( !(is_Sp_Characters_frieght(frieght.value)) || (check_char_position4(frieght.value)) )
	{
		errors = errors + '<br>' + "<li> Freight should be a number";
	}

	if( salesPerson.value < 0 )
	{
		document.salesOrderForm["salesPerson"].value = "";
	}


	if( !(is_Sp_Characters_frieght(misc.value)) || (check_char_position4(misc.value)) )
	{
		errors = errors + '<br>' + "<li>  Miscellaneous field should be a number";
	}

	var description = document.salesOrderForm["lineItemDescription"];
	var length = document.salesOrderForm["lineItemDescription"].length
	if(length == null)
	{
		if(description.value.length > 200)
		{
			   pa.innerHTML = "<li>Description Should be Maximum of 200 Characters. ";
			   description.focus();
			   description.select();
			   return;
		}
	}
	else
	{
		for(var i=0;i< length;i++)
		{
			 if(description[i].value.length > 200)
			 {
				 errors =errors + "<li>Description Should be Maximum of 200 Characters. ";
				 description[i].focus();
				 description[i].select();
				 return;
			 }

		}
	}

	var method1     = document.salesOrderForm.shippingMethod.value;
	var account1    = document.salesOrderForm.shippingAccount.value;
	var newmethod1  = document.salesOrderForm.newshippingMethod.value;
	var newaccount1 = document.salesOrderForm.newshippingAccount.value;

	if( method1 == -2)
	{
		 var tmpErrors = '';
		 if( trim(newmethod1) == '')
		 {
			 tmpErrors = '<li> Enter <bean:message key="label.sales.salesOrder.NewShippingMethod"/>';
			 document.salesOrderForm.newshippingMethod.focus();
		 }
		 if( trim(newaccount1) == '')
		 {
			tmpErrors = tmpErrors + '<li> Enter <bean:message key="label.sales.salesOrder.NewShippingAccount"/> ';
			document.salesOrderForm.newshippingAccount.focus();
		 }

		if( newmethod1.indexOf('\'') >=0 || newmethod1.indexOf('"') >=0 || newmethod1.indexOf('#') >= 0 )
		{
			 tmpErrors = tmpErrors + '<li> Enter Valid <bean:message key="label.sales.salesOrder.NewShippingMethod" /> ( \' " # are not allowed ) ';
			 document.salesOrderForm.newshippingMethod.select();
			 document.salesOrderForm.newshippingMethod.focus();
		}
		if( newaccount1.indexOf('\'') >= 0 || newaccount1.indexOf('"') >=0 || newaccount1.indexOf('#') >= 0 )
		{
			 tmpErrors = tmpErrors + '<li> Enter Valid <bean:message key="label.sales.salesOrder.NewShippingAccount" /> ( \' " # are not allowed ) ';
			 document.salesOrderForm.newshippingAccount.select();
			 document.salesOrderForm.newshippingAccount.focus();
		}
		<%
		if( Constants.SALES_INTEGRATION_TYPE_GREAT_PLAINS.equals( ConfigManager.getSalesIntegrationType() ) )
		{
		%>
			var tempShippingMethod =  newmethod1.trim();
			for(var i = 0; i < shppingLables.length - 1; i++)
			{
				if(  shppingLables[i].substring( 0, shppingLables[i].indexOf("#") ).toUpperCase().trim() == tempShippingMethod.toUpperCase() )
				{
					tmpErrors = tmpErrors + '<li>' + newmethod1 + ' <bean:message key="label.sales.salesOrder.ShippingMethod" /> already Exists, Please enter another <bean:message key="label.sales.salesOrder.ShippingMethod" />';
					document.salesOrderForm.newshippingMethod.select();
					document.salesOrderForm.newshippingMethod.focus();
				}
			}
		<%
		}
		else
		{
		%>
			var tempShippingMethod =  newmethod1.trim()+'   #   '+newaccount1.trim();
			for(var i = 0; i < shppingLables.length - 1; i++)
			{
				if(  shppingLables[i].toUpperCase() == tempShippingMethod.toUpperCase() )
				{
					tmpErrors = tmpErrors + '<li>' + newmethod1 + ' <bean:message key="label.sales.salesOrder.ShippingMethod" /> already Exists, Please enter another <bean:message key="label.sales.salesOrder.ShippingMethod" />';
					document.salesOrderForm.newshippingMethod.select();
					document.salesOrderForm.newshippingMethod.focus();
				}
			}
		<%
		}
		%>
		if( trim(tmpErrors) != '' )
		{
			var pa=document.getElementById("error");
			pa.innerHTML = tmpErrors;
			return;
		}
	}

	if( document.salesOrderForm.salesTaxType.value == -1)
    {
		var newState = document.salesOrderForm.newSalesState.value.trim();
        var newTax = document.salesOrderForm.newSalesTax.value.trim();

		if( newState.length == 0 || newState == '')
        {
			errors = errors + '<br>' + "<li>  Please enter New State ";
        }
        if( newTax.length == 0 || newTax == '')
        {
			errors = errors + '<br>' + "<li>  Please enter New Tax ";
        }
        if( (newState.length == 0 || newState == '') &&  (newTax.length == 0 || newTax == ''))
        {
			errors = ''
            errors = errors + '<br>' + "<li> Please enter values for New State and New Tax";
        }
        if(  newState.length != 0 && newState != '')
        {
			if( !(is_Sp_Characters_State(newState)) || (check_char_position5(newState)) )
			{
				errors = errors + '<br>' + "<li>  Please enter a valid state ";
			}
		}
		if( newTax.length != 0 && newTax != '')
        {
			var hh = 0;
            if( !(is_Sp_Characters_frieght(newTax)) || (check_char_position4(newTax)) )
            {
				errors = errors + '<br>' + "<li> New sales tax should be a number";
			}
			else if(newTax == 0)
			{
				errors = '';
				errors = errors +'<br>' + "<li>  New Tax cannot be less than or equal to zero";
			}

			for( var d = 0; d < newTax.length; d++ )
			{
				var c = ( newTax ).charAt(d);
				if( c == '.' )
				{
					hh++;
					if(hh > 1)
					{
						errors = '';
						errors = errors +'<br>' + "<li> New Tax should be valid number and first digit cannot be space or zero ";
						break;
					}
				}
			}
		}
	}

	var statename1 = document.salesOrderForm["salesTaxType"];
	var status = false;
	var partNbrIdx = -1;

	for( var txble=1; txble < count; txble++ )
    {
		var txval = "isTaxable"+txble;
        if(document.salesOrderForm[txval] != null)
        {
			partNbrIdx++;
            if( document.salesOrderForm[txval].checked == true )
			{

				if(document.salesOrderForm["quantity"].length == null)
				{

					if(partNo.value != '')
					{
						if( !(partNo.value == '---- BOARD -----' || partNo.value == '---- KIT -----' || partNo.value == '---- CHIPS -----') )
						{
							status = true;
						}
					}
				}
				else
				{
					if(partNo[partNbrIdx].value != '')
					{
						if( !(partNo[partNbrIdx].value == '---- BOARD -----' || partNo[partNbrIdx].value == '---- KIT -----' || partNo[partNbrIdx].value == '---- CHIPS -----') )
						{
							status = true;
						}
					}
				}

				if( (statename1.value == 0) && (status == true) )
				{
					errors = errors+ '<br>' +"<li>  Please either select Tax from Sales Tax State or uncheck Taxable field";
					break;
				}
			}
        }
	}
	if( (statename1.value != 0) && (status == false))
	{
		errors = errors+ '<br>' +"<li>  Please either check atleast one Taxable field or Select NonTaxable option";
	}

	var shipTerms = document.salesOrderForm.shippingTerms.value;
	var newshipTerms = document.salesOrderForm.newShippingTerms.value;
	var deliveryTerms = document.salesOrderForm.deliveryTerms.value;
	var newDeliveryTerms = document.salesOrderForm.newDeliveryTerms.value;

	if( shipTerms == -2)
	{
		if( newshipTerms == '' || newshipTerms.trim().length == 0 )
		{
			errors = '<br>'+'<li> Enter New Pay Terms ';
		}
		else if( newshipTerms.indexOf('\'') >=0 || newshipTerms.indexOf('"') >= 0 )
		{
			errors = '<br>'+'<li> Enter Valid Pay Terms ';
			document.salesOrderForm.newShippingTerms.select();
			document.salesOrderForm.newShippingTerms.focus();
		}
	}
	if ( deliveryTerms == -2 )
	{
		if ( newDeliveryTerms == '' || newDeliveryTerms.trim().length == 0 )
		{
			errors = errors+'<br>'+'<li> Enter New <bean:message key="label.sales.salesOrder.DeliveryTerms" />'
		}
		else if( newDeliveryTerms.indexOf('\'') >= 0 || newDeliveryTerms.indexOf('"') >= 0)
		{
			errors = errors+'<br>'+'<li> Enter Valid <bean:message key="label.sales.salesOrder.DeliveryTerms" />';
			document.salesOrderForm.newDeliveryTerms.select();
			document.salesOrderForm.newDeliveryTerms.focus();
		}
	}

	var pa = document.getElementById("errors");
    pa.innerHTML = errors;

	if( errors != '')
	{
		var pa=document.getElementById("errors");
		pa.innerHTML = errors;
		return;
	}

	if(action == 'UPDATE')
	{
		document.salesOrderForm.action.value = "UpdateChangeOrder";
	}
	else if(action == 'SUBMIT')
	{
		document.salesOrderForm.action.value = "SubmitChangeOrder";
	}
	else if(action == 'CANCELORDER')
	{
		document.salesOrderForm.action.value = "SubmitChangeOrder";
		var x = eval( document.salesOrderForm["lineItemId"] );
		if( x.name == 'lineItemId' )
		{
			document.salesOrderForm.cancel0.checked = true;
		}
		else
		{
			for( var i = 0; i< x.length; i++)
			{
				var y = eval("document.salesOrderForm.cancel"+i);
				y.checked=true;
			}
		}
	}

	var x = eval( document.salesOrderForm["manufacturingPartNo"] );
	if( x.name == 'manufacturingPartNo' )
	{
		document.salesOrderForm.manufacturingPartNo.disabled = false;
	}
	else
	{
		for(var i=0; i< x.length; i++)
		{
			x[i].disabled=false;
		}
	}

	var z = eval( document.salesOrderForm["quantity"] );
	if( z.name == 'quantity' )
	{
		document.salesOrderForm.quantity.disabled = false;
	}
	else
	{
		for(var j=0; j< z.length; j++)
		{
			z[j].disabled=false;
		}
	}

	var reqDt = eval( document.salesOrderForm["requestDate"] );
	if( reqDt.name == 'requestDate' )
	{
		document.salesOrderForm.requestDate.disabled = false;
	}
	else
	{
		for(var j=0; j< reqDt.length; j++)
		{
			reqDt[j].disabled=false;
		}
	}
	var pric = eval(document.salesOrderForm["unitPriceAsDouble"]);
	if( pric.name == 'unitPriceAsDouble' )
	{
		document.salesOrderForm.unitPriceAsDouble.disabled = false;
	}
	else
	{
		for( var j=0; j< pric.length; j++)
		{
			pric[j].disabled=false;
		}
	}

	for( var txble=0; txble < count; txble++ )
	{
		var isTaxabl = eval(document.salesOrderForm["isTaxable"+txble]);

		if ( ( isTaxabl != null ) && ( isTaxabl.disabled == true ) )
		{
			if ( isSample != 0 )
			{
				isTaxabl.disabled = false;
			}
		}
	}

	var y = eval(document.salesOrderForm["lineItemDescription"]);
    if( y.name == 'lineItemDescription')
	{
		document.salesOrderForm.lineItemDescription.disabled = false;
    }
	else
	{
		for( var j = 0; j < y.length; j++)
		{
			y[j].disabled=false;
		}
	}



	if(document.salesOrderForm["quantity"].length==null)
	{
		var element = eval("document.salesOrderForm.zeroPrice"+(document.salesOrderForm.lineItemNo.value));
		if(element.checked == true &&  price.value > 0 )
		{
			pa.innerHTML = "<li>Price field cannot take a value greater than zero when \" zero price \" option is selected";
			price.focus();
			return;
		}
		if( !(document.salesOrderForm.poLineItemNo.disabled ))
		{
			if ( document.salesOrderForm.poLineItemNo.value.trim() == "" )
			{
				pa.innerHTML = "<li>Please Enter PO Line Item Number ";
				document.salesOrderForm.poLineItemNo.focus();
				return;
			}
			else if ( !(isInteger( document.salesOrderForm.poLineItemNo.value ) ) ||  document.salesOrderForm.poLineItemNo.value == 0 )
			{
				pa.innerHTML = "<li>&nbsp;Please enter a valid PO Line Item Number";
				document.salesOrderForm.poLineItemNo.focus();
				return;
			}
		}
	}
	else
	{
		var zeroPriceCount = document.salesOrderForm["quantity"].length;
		var po_lineitem_no = document.salesOrderForm["poLineItemNo"];

		for(i=0;i< zeroPriceCount;i++)
		{
			if(qty[i].value > 0 )
			{
				var value = (document.salesOrderForm.lineItemNo[i].value);
				var element = eval("document.salesOrderForm.zeroPrice"+value);
				if(element.checked == true &&  price[i].value > 0 )
				{
					pa.innerHTML = "<li>Price field cannot take a value greater than zero when \" zero price \" option is selected";
					price[i].focus();
					return;
				}
				if( !( po_lineitem_no[i].disabled ) )
				{
					if ( po_lineitem_no[i].value.trim() == "" )
					{
						pa.innerHTML = "<li>Please Enter PO Line Item Number ";
						po_lineitem_no[i].focus();
						return;
					}
					else if ( !( isInteger( po_lineitem_no[i].value ) )  ||  po_lineitem_no[i].value == 0 )
					{
						pa.innerHTML = "<li>&nbsp;Please enter a valid PO Line Item Number";
						po_lineitem_no[i].focus();
						return;
					}
				}
			}
		}
	}

	var po_lineitem = eval(document.salesOrderForm["poLineItemNo"]);
	if(po_lineitem.name == 'poLineItemNo')
	{
		document.salesOrderForm.poLineItemNo.disabled = false;
	}
	else
	{
		for(var j=0; j< po_lineitem.length; j++)
		{
			po_lineitem[j].disabled = false;
		}
	}

	var lineitem = eval(document.salesOrderForm["lineItemNo"]);
	if( lineitem.name == 'lineItemNo')
	{
		document.salesOrderForm.lineItemNo.disabled = false;
		( eval ( "document.salesOrderForm.zeroPrice" + ( document.salesOrderForm.lineItemNo.value ) ) ).disabled = false;

	}
	else
	{
		for(var j=0; j< lineitem.length; j++)
		{
			lineitem[j].disabled=false;
			( eval( "document.salesOrderForm.zeroPrice" + ( document.salesOrderForm.lineItemNo[j].value ) ) ).disabled = false;
		}
	}

	document.salesOrderForm.shippingAddress.disabled = false;
	document.salesOrderForm.billingAddress.disabled = false;
	document.salesOrderForm.phoneNumber.disabled = false;
	document.salesOrderForm.faxNumber.disabled = false;
	document.salesOrderForm.email.disabled = false;
	document.salesOrderForm.shippingAccount.disabled=false;
	document.salesOrderForm.contactPerson.disabled = false;

	document.salesOrderForm.salesTaxType.disabled = false;
	document.salesOrderForm.miscAsDouble.disabled = false;
	document.salesOrderForm.frieghtAsDouble.disabled = false;


	for( var cancl = 0; cancl < count; cancl++ )
	{
		var isCancelled = eval(document.salesOrderForm["cancel"+cancl]);

		if ( (isCancelled != null) && (isCancelled.disabled == true))
		{
			isCancelled.disabled = false;
		}
	}

	if(document.salesOrderForm.contactPerson.value == -1 || document.salesOrderForm.contactPerson.value == '')
	{
		document.salesOrderForm.phoneNumber.value="";
		document.salesOrderForm.faxNumber.value="";
		if(document.salesOrderForm.cellNumber != null)
		{
			document.salesOrderForm.cellNumber.value="";
		}
		document.salesOrderForm.email.value="";
	}

	enableCustPartNos();
	enablePrices();

	document.salesOrderForm.submit();
}
function addShippingMethod(methodname)
{
	var pa11=document.getElementById("shippingAccount");
	var pa1=document.getElementById("newshippingMethod");
	var pa3=document.getElementById("newshippingAccount");



	if (methodname.value == -2)
	{
        var form = document.salesOrderForm;
        document.salesOrderForm.shipAccount1.value=-1;
        form.shippingMethod.value = -1;
        form.shippingMethodName.value = " ";
        form.shippingAccount.value = " ";
        var LeftPos=(screen.width)?(screen.width-500)/2:100;
        var TopPos=(screen.height)?(screen.height-450)/2:100;
        newWindow = window.open ('<%=chipTracContext%>/shippingMethodPopupAction.do?action=load&customerId='+form.customerId.value+"&endCustomerId="+form.odmId.value,"editShippingMethod",'channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=yes,scrollbars=yes,width=540,height=500,resizable=yes,Left= '+LeftPos+',top='+TopPos);
        newWindow.focus();

    }
	else
	{
        document.salesOrderForm.shipAccount1.value = document.salesOrderForm.shippingMethod.value;
        document.salesOrderForm.newshippingMethod.value='';
		document.salesOrderForm.newshippingAccount.value='';

		if (methodname.value == -1)
		{
			document.salesOrderForm.shippingMethodName.value = " ";
			document.salesOrderForm.shippingAccount.value = " ";
		}

		 document.salesOrderForm.newshippingMethod.style.visibility = "hidden";
		 pa1.innerHTML = "&nbsp;";
		 document.salesOrderForm.newshippingAccount.style.visibility = "hidden";
		 pa3.innerHTML = "&nbsp;";

		assignShippingAccount(methodname);
	}
}
function AddDeliveryTerms ()
{
	var deliveryTermsLabel = document.getElementById("newDeliveryTerms");
	if(document.salesOrderForm.deliveryTerms.value == -2 )
	{
		 document.salesOrderForm.newDeliveryTerms.style.visibility = "visible";
		 document.salesOrderForm.newDeliveryTerms.value = '';
		 deliveryTermsLabel.innerHTML = "New <bean:message key="label.sales.salesOrder.DeliveryTerms" /> : ";
		 document.salesOrderForm.newDeliveryTerms.focus();
	}
	else
	{
		 document.salesOrderForm.newDeliveryTerms.style.visibility = "hidden";
		 deliveryTermsLabel.innerHTML = "";
	}
}

function addNewSalesTaxType(statename)
{
	var p1=document.getElementById("font-1");
	var p2=document.getElementById("font-2");
	var p3=document.getElementById("font-3");
	var p4=document.getElementById("font-4");
	p1.innerHTML = "";
	p2.innerHTML = "";
	p3.innerHTML = "";
	p4.innerHTML = "";

	if(statename.value == -1)
	{
		var htmltext1 = '<font class="NArialL">New State :</font>&nbsp;'
		var htmltext2 = '<input type="text" name="newSalesState" size="18" maxlength="25" class="txfield" onblur = "document.salesOrderForm.newSalesTax.focus();">'
		var htmltext3 = '<font class="NArialL">New Tax :</font>&nbsp;'
		var htmltext4 = '<input type="text" name="newSalesTax" size="18" class="txfield" maxlength="6" onkeypress="javascript:restrictCharacters(this,3,<%=ConfigManager.getnoOfDecmalsInAmount()%>)" onkeyup="javascript:restrictAmt(this,3,<%=ConfigManager.getnoOfDecmalsInAmount()%>)">'

		p1.insertAdjacentHTML('BeforeEnd',htmltext1);
		p2.insertAdjacentHTML('BeforeEnd',htmltext2);

		p3.insertAdjacentHTML('BeforeEnd',htmltext3);
		p4.insertAdjacentHTML('BeforeEnd',htmltext4);
	}
}
<%--<%=ChangeOrderAction.getMapScript( salesOrderFromMap.getMfgPartsWithComments(), "comments", true)%>--%>
      var keys = new Array();
      var comments = new Array();

    <%
      try{
            mfgList = salesOrderFromMap.getMfgParts();
            if( mfgList == null)  mfgList =  new java.util.ArrayList();
            mfgListsize = mfgList.size();
            int commentCount = 0;
            strBuffer = new StringBuffer();
            for( int j = 0; j < mfgListsize; j++)
            {
                customerPartNo = (CustomerPartNumber)mfgList.get(j);
                strBuffer.append("keys[").append(commentCount).append("]='").append(customerPartNo.getManufacturingPartNo()).append("';\n");
                out.print( "comments["+commentCount+"]='");
                if ( customerPartNo.getComments() != null)
                {
                    out.print(StringUtils.escapeSpecialString(customerPartNo.getComments()));
                 }
                out.println("';");
                commentCount++;
            }
            out.println(strBuffer.toString());
        }
        catch(Exception ex)
        {   //ex.printStackTrace();
            System.out.println(ex);
        }
    %>
<%=ChangeOrderAction.getMapScript( salesOrderFromMap.getMfgPartsWithCustomerPartNos(), "customernos", false)%>
<%if ( ConfigManager.getBooleanProperty(ConfigManager.PROP_SHOW_SALES_LINEITEM_BASE_ORDER_QTY) )
{
%>
<%=ChangeOrderAction.getMapScript( salesOrderFromMap.getMfgPartsWithBaseOrderQty(), "baseOrderQty", false)%>
<%
}
%>
<%--<%=ChangeOrderAction.getMapScript( salesOrderFromMap.getMfgPartsWithLabelNumbers(), "labelnos", false)%>--%>
function showErrorReportPage()
{
    newWindow = window.open ('<%=chipTracContext%>/reportProblem.do','reportProblem','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=no,width=750,height=400,resizable=no');
    newWindow.focus();
}

function selectCustomerSalesPersonRelation()
{
    var customerId = document.salesOrderForm.customerId.value ;
    var customerName = document.salesOrderForm.customerName.value;
    var odmId = document.salesOrderForm.odmId.value ;
    var LeftPos=(screen.width)?(screen.width-500)/2:100;
    var TopPos=(screen.height)?(screen.height-450)/2:100;
    newWindow = window.open ('<%=chipTracContext%>/customerSalesPersonRelationship.do?action=searchSalesPersons&customerId='+customerId+'&odmId='+odmId,'customerSalespersons','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=yes,scrollbars=yes,width=540,height=500,resizable=yes,Left= '+LeftPos+',top='+TopPos);
    if(!newWindow.opener) {newWindow.opener = window}
    newWindow.focus();
}
function partNoGenerator(lineItemIdx)
{
    var form = document.salesOrderForm;
    form.partLineItemNo.value = lineItemIdx;
    var pa = document.getElementById("errors");
    pa.innerHTML = "";
    newWindow = window.open('<%=chipTracContext%>/jsp/partnumber-generator/PartNumberGenerators.html','PartNumberGeneratorsPopup','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=yes,width=650,height=525,resizable=yes');
    newWindow.focus();
}

</SCRIPT>

<!-- Top Header Start-->
    <%
        String userTypeChiptrac = Constants.USER_TYPE_CHIPTRAC + "";
    %>
    <logic:equal value="<%=userTypeChiptrac%>" name="user" property="userType" scope="session">
        <%@ include file="/jsp/includes/header.jsp" %>
    </logic:equal>
    <logic:notEqual value="<%=userTypeChiptrac%>" name="user" property="userType" scope="session">
        <%@ include file="/jsp/includes/extHeader.jsp" %>
    </logic:notEqual>

<!-- Top Header End-->

<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
    <TBODY>
    <TR>
        <td width='180' valign='top' background='<%=chipTracContext%>/jsp/includes/images/left_red_bg.gif'>
        <!-- Side Navigation start -->
        <% String heading = ""; %>
        <%
            if((request.getParameter("isSample") != null) && (request.getParameter("isSample").equals("0")))
            {
                heading = "Sample Order";
        %>
            <logic:equal value="<%=userTypeChiptrac%>" name="user" property="userType" scope="session">
                <%@ include file="/jsp/sales/sample_order_menu.jsp" %>
            </logic:equal>
            <logic:notEqual value="<%=userTypeChiptrac%>" name="user" property="userType" scope="session">
                <%@ include file="/jsp/sales/ext_sample_order_menu.jsp" %>
            </logic:notEqual>
        <%  }
            else
            {
                heading = "Sales Order";
        %>
            <logic:equal value="<%=userTypeChiptrac%>" name="user" property="userType" scope="session">
                <%@ include file="/jsp/sales/sales_order_menu.jsp" %>
            </logic:equal>
            <logic:notEqual value="<%=userTypeChiptrac%>" name="user" property="userType" scope="session">
                <%@ include file="/jsp/sales/ext_sales_order_menu.jsp" %>
            </logic:notEqual>
        <%  } %>
    </TD>
    <TD bgcolor="#ffffff"><IMG height=9 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=8></TD>
    <TD bgcolor="#ffffff"><IMG height=480 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=2></TD>
    <TD valign="top" width="100%">
        <IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/clear.gif" width=500 border=0>
        <BR>
        <html:html>
        <table width=75%><tr><td ><center><span class="NArialW"><%=heading%> Entry</span></center></td></tr></table>
        <img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10>
        <table border="0" width="95%" align=right>
        <html:form name="salesOrderForm" action="/changeOrder" method="post" scope= "request" type="com.scalar.chiptrack.sales.forms.SalesOrderForm">
        <% SalesOrderForm salesOrderForm = (SalesOrderForm) request.getAttribute("salesOrderForm"); %>
        <a name="#e1"></a>
            <tr><td colspan=7 class="NArialL"><chiptrack:errors styleClass="NArialL" /></td></tr>
            <tr><td colspan='7' align="left" class='NArialL'><FONT id="error" styleClass="NArialL" color='FF0000'></FONT></TD></TR>
            <tr><td colspan='7' align="left" class='NArialL'><FONT id="error1" styleClass="NArialL" color='FF0000'></FONT></TD></TR>
            <%boolean showMessage = request.getAttribute("showMessage")!=null&&"true".equalsIgnoreCase((String)request.getAttribute("showMessage"));
                if(showMessage){
            %>
            <tr>
                <td colspan=7 align='left'>
                    <font class='NArialS'><font color='blue'><b><%=Constants.NO_MODIFY_RIGHTS %></b></font></font>
                </td>
            </tr>
            <%}%>
            <tr>
                <td width="13%"><font class="NArialL">Sales Order No :&nbsp;<font color=red>*</font></font></td>
                <td width="18%" class="bodytext"><b><bean:write name="salesOrderForm" property="salesOrderNo" /></b></td>
                <td width="15%"><font class="NArialL">Customer Name :</font></td>
                <td width="20%" class="NArialL"><bean:write name="salesOrderForm" property="customerName" /></td>
                <td width="22%">&nbsp;</td>
                <td width="11%">&nbsp;</td>
            </tr>
            <tr>
                <td width="13%"><font class="NArialL">Change No :</font></td>
                <td width="18%" class="bodytext"><b><bean:write name="salesOrderForm" property="changeNo" /></b></td>
                <td width="15%" class="NArialL">Reason :</td>
                <td width="20%" class="NArialL"><html:text name="salesOrderForm" property="reason" styleClass="txfield" size="23" /></td>
                <td width="22%">&nbsp;</td>
                <td width="11%">&nbsp;</td>
            </tr>
            <tr>
                <td width="13%">
                    <font class="NArialL">Customer PO No :&nbsp;
                    <logic:notEqual parameter="isSample" value="0">
                        <font color=red>*</font>
                    </logic:notEqual>
                    </font>
                </td>
				<td width="18%">
                    <html:text name="salesOrderForm" property="customerPO" styleClass="txfield" size="23" onkeyup="" maxlength="50"/>
                </td>
				<td width="15%"><font class="NArialL">Contact Person :</font></td>
				<td width="20%">
					<html:select name="salesOrderForm" property="contactPerson" styleClass="txfield" onchange="javascript:selectContactPerson('CustomerContactPerson',0);">
						<html:option value="">--- Select ---</html:option>
						<html:options name="contactPersons" />
					</html:select>
				</td>
				<td width="22%">&nbsp;</td>
				<td width="11%">&nbsp;</td>
			</tr>
            <%--<tr><td colspan=4><font class="NArialL">Please <chiptrack:attachFile fileGroup="SalesOrder-PO" fileSubGroup="<%=salesOrderForm.getSalesOrderNo()%>" formTitle="Attach Sales PO" linkText="click here" allowAttach="<%=!showMessage%>" allowDelete="<%=!showMessage%>"/> to View and Attach PO</font></td></tr>--%>
            <tr>
				<td width="13%"><font class="NArialL"><bean:message key="label.sales.salesOrder.PoRevisionNumber"/> :</font></td>
				<td width="18%"><html:text name="salesOrderForm" property="poRev" size="23" styleClass="txfield" /></td>
				<td width="15%"><font class="NArialL"><bean:message key="label.sales.salesOrder.PoDate"/> :</td>
				<td width="20%"><html:text name="salesOrderForm" property="poDate" size="23" styleClass="txfield" />
					<a href="javascript:openCalendar(document.salesOrderForm.poDate)"><img onMouseOver="window.status='Click here to select date';return true" border="0" align='center' src="<%=chipTracContext%>/jsp/includes/images/date_selector.gif" height=20 width=20></a>
				</td>
				<td width="22%">&nbsp;</td>
				<td width="11%">&nbsp;</td>
			</tr>
			<tr>
				<td width="13%"><font class="NArialL">Phone :</font></td>
				<td width="18%"><html:text name="salesOrderForm" property="phoneNumber" size="23" styleClass="txfield" onkeypress='validatePhoneNumber(this)'/></td>
				<td width="15%"><font class="NArialL">Cell No :</font></td>
				<td width="20%"><html:text name="salesOrderForm" property="cellNumber" size="23" styleClass="txfield" onkeypress='validatePhoneNumber(this)'/></td>
				<td width="22%">&nbsp;</td>
				<td width="11%">&nbsp;</td>
			</tr>
			<tr>
				<td width="13%"><font class="NArialL">Fax :</font></td>
				<td width="18%"><html:text name="salesOrderForm" property="faxNumber" size="23" styleClass="txfield" onkeypress='validatePhoneNumber(this)'/></td>
				<td width="15%"><font class="NArialL">Email :</font></td>
				<td width="20%"><html:text name="salesOrderForm" property="email" size="23" styleClass="txfield" /></td>
				<td width="22%">&nbsp;</td>
				<td width="11%">&nbsp;</td>
			</tr>
			<% SalesOrderForm salesform = (SalesOrderForm)request.getAttribute("salesOrderForm"); %>
			<tr>
				<td width="13%"><font class="NArialL">Sales Person :</font></td>
				<td width="18%">
					<html:select name="salesOrderForm" property="salesPerson" styleClass="txfield" >
						<html:option value="" >----- Select -----</html:option>
						<html:options collection="salesPersons" property="value" labelProperty="label"/>
					</html:select>
					<input type="hidden" name="salesPersonName" value="<%=salesOrderForm.getSalesPerson()%>"/>
				</td>
				<td width="15%"><font class="NArialL"><bean:message key="label.sales.salesRep.Name"/> :</font></td>
				<td width="20%">
					<html:select name="salesOrderForm" property="salesRep" styleClass="txfield" >
						<html:option value="" >----- Select -----</html:option>
						<html:options collection="salesReps" property="value" labelProperty="label"/>
					</html:select>
					<input type="hidden" name="salesRep" value="<%=salesOrderForm.getSalesRep()%>"/>
				</td>
				<td width="22%">&nbsp;</td>
				<td width="11%">&nbsp;</td>
			</tr>
		    <tr>
		        <td width="20%" colspan="4">
					<font class="NArialL">
					Please <a styleClass="leftsection" href="javascript:selectCustomerSalesPersonRelation()" onmouseover="window.status='Click to select Customer/Sales Person Relationship';return true" onmouseout="window.status='';return true">Click here</a>
					&nbsp;to Add Customer/Sales Person Relationships
					</font>
				</td>
				<td width="22%">&nbsp;</td>
				<td width="11%">&nbsp;</td>
			</tr>
			<tr>
				<td width="13%"><font class="NArialL"><bean:message key="label.sales.salesOrder.ShippingMethod" /> :</font></td>
				<td width="18%">
					<select name="shippingMethod" class="txfield" onchange="javascript:addShippingMethod(this);">
					<% request.setAttribute("Method",salesOrderForm.getShippingMethod()); %>
					<% request.setAttribute("Account",salesOrderForm.getShippingAccount()); %>
					<option value="-1" >----- Select -----</option>
					<% java.util.ArrayList shippingMethods = null;
					boolean flagValue = false;
		            try
                    {
			            if( request != null )
                        {
                            selectedMethod = (String)request.getAttribute("Method");
                            selectedAccount = (String)request.getAttribute("Account");

					        shippingMethods = salesOrderFromMap.getShippingMethods ();
                            org.apache.struts.util.LabelValueBean shippingMethod;
				            for( int j = 0; j < shippingMethods.size(); j++ )
                            {
					            shippingMethod = ( org.apache.struts.util.LabelValueBean ) shippingMethods.get( j );

					            String label = shippingMethod.getLabel();
                                String value = shippingMethod.getValue();

					            if( selectedMethod != null)
					            {
					                if( ( selectedMethod.trim() ).equalsIgnoreCase( label.trim() ) )
					                {
                    %>
						            <option value="<%=selectedMethod%>" selected><%=selectedMethod%></option>
                    <%
                                    }
                                    else if ( "'".equalsIgnoreCase( value ) )
                                    {
                    %>
                                    <option value="-1" ><%=label%></option>
                    <%              }
                                    else
                                    {
                    %>
                                    <option value="<%=label%>" ><%=label%></option>
					<%
                                    }
					            }
                                else
                                {
                    %>
                                <option value="<%=label%>" ><%=label%></option>
					<%          }
				            }
			            }
			        }
                    catch(NullPointerException e) {e.printStackTrace();}
			        %>
				    <option value="-2" >----- Edit -----</option>
                    </select>
	            </td>
				<td width="15%" class="NArialL">
					Quotation No :
					<input type="hidden" name="shippingAccount" value="<%=salesOrderForm.getShippingAccount() != null ? salesOrderForm.getShippingAccount() : ""%>">
				</td>
				<td width="22%" class="NArialL">
						<html:text name="salesOrderForm" property="quotationNo" styleClass="txfield"  />
				</td>
				<td width="11%">&nbsp;</td>
			</tr>
			<tr>
				<td width="13%"><font class="NArialL" id="newshippingMethod"><bean:message key="label.sales.salesOrder.NewShippingMethod"/>:</font></td>
				<td width="18%"><html:text name="salesOrderForm" property="newshippingMethod" size="23" styleClass="txfield" maxlength="50" onkeyup="" /></td>
				<td width="15%"><font class="NArialL" id="newshippingAccount"><bean:message key="label.sales.salesOrder.NewShippingAccount"/>:</font></td>
				<td width='20%'><html:text name="salesOrderForm" property="newshippingAccount" size="23" styleClass="txfield" maxlength="50" /></td>
				<td width="22%">&nbsp;</td>
				<td width="11%">&nbsp;</td>
			</tr>
			<tr>
				<td width="13%"><font class="NArialL">Pay Terms :</font></td>
				<td width="18%">
                    <html:select name="salesOrderForm" property="shippingTerms" styleClass="txfield"  onchange="javascript:AddShippingTerms()">
                        <option value="" >----- Select -----</option>
                        <html:options name="allShippingTerms" />
                        <html:option value="-2" >-- Add New Pay Terms --</html:option>
                    </html:select>
                </td>
                <td width="15%"><font class="NArialL"><bean:message key="label.sales.salesOrder.DeliveryTerms" /> :</font></td>
                <td width="20%">
                    <html:select name="salesOrderForm" property="deliveryTerms" styleClass="txfield" onchange="javascript:AddDeliveryTerms()">
                       <option value="" >----- Select -----</option>
                       <html:options name="allDeliveryTerms"/>
                       <html:option value="-2">-- Add New <bean:message key="label.sales.salesOrder.DeliveryTerms" /> --</html:option>
                    </html:select>
                </td>
                <td width="22%">&nbsp;</td>
                <td width="11%">&nbsp;</td>
            </tr>

            <tr>
                <td width="13%"><font class="NArialL" id="newShippingTerms">New Pay Terms:</font></td>
                <td width="18%"><html:text name="salesOrderForm" property="newShippingTerms" size="23" maxlength="<%=ConfigManager.getProperty(ConfigManager.PAYMENT_TERMS_MAX_LENGTH)%>" styleClass="txfield" /></td>
                <td width="15%"><font class="NArialL" id="newDeliveryTerms">New <bean:message key="label.sales.salesOrder.DeliveryTerms" /> :</font></td>
                <td width='20%'><html:text name="salesOrderForm" property="newDeliveryTerms" size="23" maxlength="50" styleClass="txfield" /></td>
                <td width="22%">&nbsp;</td>
                <td width="11%">&nbsp;</td>
            </tr>
            <tr>
				<td width="13%"><font class="NArialL">&nbsp;</font></td>
				<td width="18%">&nbsp;</td>
                <html:hidden property="isConsignee" name="salesOrderForm"/>
                <html:hidden property="isConsignmentSales" name="salesOrderForm"/>
                <logic:equal value="true" name="salesOrderForm" property="isConsignee">
                <td width="15%" class="NArialL">Invoice to Customer : </td>
                    <td width="20%" class="bodytext">
                        <logic:equal value="0" name="salesOrderForm" property="isConsignmentSales">No</logic:equal>
                        <logic:notEqual value="0" name="salesOrderForm" property="isConsignmentSales">Yes</logic:notEqual></td>
                </logic:equal>
                <logic:notEqual value="0" name="salesOrderForm" property="isConsignmentSales">
                    <td width="15%">&nbsp;</td>
                    <td width="20%">&nbsp;</td>
                </logic:notEqual>
                <td width="22%">&nbsp;</td>
                <td width="11%">&nbsp;</td>
			</tr>
            <tr>
				<td width="13%"><font class="NArialL">Regional Rep :</font></td>
				<td width="18%">
					<html:text name="salesOrderForm" property="regionalRep" size="23" styleClass="txfield" onkeyup="javascript:checkValidity('Regional Rep')" />
				</td>
				<td width="15%"><font class="NArialL">Booking Date :&nbsp;<font color=red>*</font></font></td>
				<td width="20%">
					<logic:equal name= "salesOrderForm" property="status" value="SHIPPED">
						<html:text name="salesOrderForm" property="salesOrderDate" size="23" styleClass="txfield" disabled="true"/>
					</logic:equal>
					<logic:notEqual name= "salesOrderForm" property="status" value="SHIPPED">
						<html:text name="salesOrderForm" property="salesOrderDate" size="23" styleClass="txfield"/>
						<a href="javascript:openCalendar(document.salesOrderForm.salesOrderDate)"><img onMouseOver="window.status='Click here to select date';return true" border="0" align='center' src="<%=chipTracContext%>/jsp/includes/images/date_selector.gif" height=20 width=20></a>
					</logic:notEqual>
				</td>
                <td width="22%">&nbsp;</td>
                <td width="11%">&nbsp;</td>
			</tr>
		<tr>
			<td width="13%"><font class="NArialL"><bean:message key="label.sales.userField1"/> :</font></td>
			<td width="18%"><html:text name="salesOrderForm" property="userField1" size="23" styleClass="txfield"/></td>
			<td width="15%"><font class="NArialL">
					<bean:message key="label.sales.userField2"/> :</td>
			<td width="20%"><html:text name="salesOrderForm" property="userField2" size="23" styleClass="txfield"/></td>
			<td width='22%'>&nbsp;</td>
			<td width='11%'>&nbsp;</td>
		</tr>
		<tr>
				<td width="13%"><font class="NArialL"><bean:message key="label.sales.endUser"/></font></td>
			    <td width="18%">
                    <html:select name="salesOrderForm" property="endCustomerId" styleClass="txfield" onchange="showHideNewEndUserField()">
                        <html:option value="" >----- Select -----</html:option>
                        <html:options collection="endCustomerList" property="value" labelProperty="label"/>
                        <html:option value="-2" >-----Add New-----</html:option>
                    </html:select>
                    <input type="hidden" name="endCustomer" value="" >
                    <input type="hidden" name="endUser" value="" >
                </td>
				<td width="15%"><font class="NArialL"><bean:message key="label.sales.shipToCustomer"/></font></td>
				<td width="20%">
					<html:select name="salesOrderForm" property="odmId" styleClass="txfield" onchange="javascript:getCustomerShippingAddress();">
						<html:option value="-1" >----- Select -----</html:option>
						<html:options collection="odmList" property="value" labelProperty="label"/>
                        <html:option value="-2" >-----Add New-----</html:option>
                    </html:select>
					<input type="hidden" name="odm" value="<%=salesOrderForm.getOdm()%>" >
				</td>
			   <td width="22%">&nbsp;</td>
			   <td width="11%">&nbsp;</td>
			</tr>
            <tr>
              <td class="NArialL"><span id="endUserLabelSpan" style="display:none">Add New <bean:message key="label.sales.endUser"/> :</span></td>
              <td ><span id="endUserTxfieldSpan" style="display:none"><html:text name="salesOrderForm" property="newEndUserName" styleClass="txfield"/></span></td>
              <td class="NArialL"><span id="endCustomerLabelSpan" style="display:none">Add New <bean:message key="label.sales.shipToCustomer"/></span></td>
              <td ><span id="endCustomerTxfieldSpan" style="display:none"><html:text name="salesOrderForm" property="newEndCustomerName" styleClass="txfield"/></span></td>

              <td width="22%">&nbsp;</td>
              <td width="11%">&nbsp;</td>
           </tr>

            <tr>
				<td width="13%">&nbsp;</td>
				<td width="18%">&nbsp;</td>
				<td width="15%"><font class="NArialL"><bean:message key="label.sales.shipToCustomer"/> Shipping Address :</font></td>
				<td width="20%"><html:checkbox name="salesOrderForm" property="isEndCustomerShipAddress" value="true" styleClass="txfield" onclick="javascript:getEndCustomerShippingAddress(this);" /></td>
				<td width="22%">&nbsp;</td>
				<td width="11%">&nbsp;</td>
			</tr>
			<tr>
				<% if(ConfigManager.isMultipleBillingAddressesAllowed()) { %>
               <td width="13%"><font class="NArialL">Billing Addresses :</font></td>
               <td width="18%">
                    <html:select name="salesOrderForm" property="billingAddressId" styleClass="txfield" onchange="javascript:assignAddressOfType(this,'Billing');">
                        <html:options collection="billingAddresses" property="value" labelProperty="label"/>
                    </html:select>
               </td>
               <% } else { %>
                    <td width="13%"><font class="NArialL"><html:hidden property="billingAddressId" name="salesOrderForm"/></font></td>
                   <td width="18%">&nbsp;</td>
               <% } %>
				<td width="15%"><font class="NArialL">Shipping Addresses :</font></td>
				<td width="20%">
					<html:select name="salesOrderForm" property="shippingAddressId" styleClass="txfield" onchange="javascript:assignAddressOfType(this,'Shipping');">
						<html:options collection="shippingAddresses" property="value" labelProperty="label"/>
					</html:select>
				</td>
				<td width="22%">&nbsp;</td>
				<td width="11%">&nbsp;</td>
			</tr>
			<tr>
				<td width="13%"><font class="NArialL">Contact Person :</font></td>
				<td width="18%">
					<html:select  name="salesOrderForm" property="billingContactPerson"  styleClass="txfield" onchange="javascript:selectContactPerson('BillingContactPerson',0,0);" >
						<html:option value="">--- Select ---</html:option>
						<html:options name="billingAddressContactPersons" />
					</html:select>
				</td>
				<td width="15%"><font class="NArialL">Contact Person :</font></td>
				<td width="20%">
					<html:select  name="salesOrderForm" property="shippingContactPerson"  styleClass="txfield" onchange="javascript:selectContactPerson('ShippingContactPerson',0,0);">
						<html:option value="">--- Select ---</html:option>
						<html:options name="shippingAddressContactPersons" />
					</html:select>
				</td>
				<td width="22%">&nbsp;</td>
				<td width="11%">&nbsp;</td>
			</tr>

			<tr>
				<td width="13%"><font class="NArialL">Billing Address :</font></td>
				<td width="18%"><html:textarea rows="13" name="salesOrderForm" property="billingAddress" cols="23" styleClass="txfield" disabled="true"/></td>
				<td width="15%"><font class="NArialL">Shipping Address :</font></td>
				<td width="20%">
					<html:link styleClass="NArialL" href="javascript:AddNewShippingAddress(document.salesOrderForm.shippingAddress);"  onmouseover="window.status='Click here to Add New Shipping Address';return true" onmouseout="window.status='';return true">Add new shipping Address</html:link>
					<br>
					<html:textarea name="salesOrderForm" rows="13" cols="23" property="shippingAddress" styleClass="txfield" disabled="true"/>
				</td>
				<td width="22%">&nbsp;</td>
				<td width="11%">&nbsp;</td>
			</tr>
			<tr><td colsapn=6><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></td></tr>
			<tr>
				<td width="13%"><font class="NArialL">All Freight Instructions :</font></td>
				<td width="18%">
					<html:select name="salesOrderForm" property="freightInstructionsId" styleClass="txfield" onchange="javascript:assignFreightInstructions(this);">
						<html:options collection="freightInstructions" property="value" labelProperty="label"/>
					</html:select>
				</td>
				<td width="15%"><font class="NArialL">All Shipping Instructions :</font></td>
				<td width="20%">
					<html:select name="salesOrderForm" property="shippingInstructionsId" styleClass="txfield" onchange="javascript:assignShippingInstructions(this);">
						<html:options collection="shippingInstructions" property="value" labelProperty="label"/>
					</html:select>
				</td>
				<td width="22%">&nbsp;</td>
				<td width="11%">&nbsp;</td>
			</tr>
			<tr>
				<td width="13%"><font class="NArialL" id="freightInstructionLabel">Freight Instructions :</font></td>
				<td width="18%"><html:textarea name="salesOrderForm" property="freightInstructions" rows="4" cols="36" styleClass="txfield" onkeydown="javascript:setTextAreaMaxLength(document.salesOrderForm.freightInstructions,300)" onkeyup="javascript:setTextAreaMaxLength(document.salesOrderForm.freightInstructions,300)"/></td>
				<td width="15%"><font class="NArialL" id="shippingInstructions"><bean:message key="label.sales.shippingInstructions" /></font></td>
				<td width="20%"><html:textarea name="salesOrderForm" property="shippingInstructions" rows="4" cols="35" styleClass="txfield" onkeydown="javascript:setTextAreaMaxLength(document.salesOrderForm.shippingInstructions,300)" onkeyup="javascript:setTextAreaMaxLength(document.salesOrderForm.shippingInstructions,300)"/></td>
				<td width="22%">&nbsp;</td>
				<td width="11%">&nbsp;</td>
			</tr>
			<script>setReadOnlyForFreightInsructions ( document.salesOrderForm.freightInstructionsId );</script>
			<tr>
				<td width="13%"><font class="NArialL">Comments :</font></td>
				<td width="87%" colspan="5"><html:textarea name="salesOrderForm" rows="4" property="comments" cols="100" styleClass="txfield" onkeydown="javascript:setTextAreaMaxLength(document.salesOrderForm.comments,300)" onkeyup="javascript:setTextAreaMaxLength(document.salesOrderForm.comments,300)"/></td>
			</tr>
            <%
                String commentsGroupId = "SalesOrder-" + salesOrderForm.getSalesOrderNo();
            %>
            <tr><td colspan=4><chiptrack:internalComments commentsGroupId="<%=commentsGroupId%>"/></td></tr>

			<tr><td colspan=6 class="NArialL"><font color="FF0000"><html:errors /></font></td></tr>
			<tr><td colspan=6><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=5></td></tr>
			<tr><td colspan=6>
            <%
            ArrayList previousLineItems = salesOrderFromMap.getPreviousLineItems();
            for( int j = 0; j < previousLineItems.size(); j++ )
            {
                oldCount ++;
                noOfRows ++;
            }
            %>
            <jsp:include page="previousLineItemsForChangeSalesOrder.jsp" flush="true" />
        </td>
    </tr>
    <tr><td colspan=6><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=5></td></tr>
    <tr><td colspan=6 class="NArialL" align=right><A href="javascript:openReasonCodes();" onmouseover="window.status='Click for ReasonCodes Description';return true" onMouseOut="window.status='';return true">ReasonCodes Description</A></td></tr>
    <tr><td colspan='6' align="left" class='NArialL'><FONT id="errors" styleClass="NArialL" color='FF0000'></FONT></TD></TR>
    <tr><td colspan='6' align="left" class='NArialL'><FONT id="message" styleClass="NArialL" color='FF0000'></FONT></TD></TR>
    <tr>
        <td colspan=6>
            <br>
                <font class="NArialS" color='blue'>
                <b>
                <li>&nbsp;SHIPPED or ISSUED items cannot be cancelled.
                <br>
                <li>&nbsp;Disabled rows indicate SHIPPED , PARTIALLY SHIPPED or ISSUED items and they cannot be changed.
                <br>
                <li>&nbsp;Select the zero price option if you want to keep the price as zero.
                </b>
                </font>
            <br>
        </td>
    </tr>
    <tr>
        <td colspan=6>
            <table border="0" width="95%" id="lineItemsTable">
	            <tr>
                    <td class="NArialL">&nbsp;</td>
                </tr>
                <tr>
                    <td colspan=2 class="NArialL">
                     <% if((request.getParameter("isSample") != null) && (request.getParameter("isSample").equals("0"))) { %>
                        <chiptrack:restrictedLink functionality='<%=Functionality.SAMPLE_CHANGE_ORDER%>' action='<%=User.USER_ACTION_MODIFY%>' href="javascript:splitLineItems();" onmouseover="window.status='Click here to split line items';return true" onmouseout="window.status='';return true">
                        Split Line Items</chiptrack:restrictedLink>
                    <% } else { %>
                        <chiptrack:restrictedLink functionality='<%=Functionality.SALES_CHANGE_ORDER%>' action='<%=User.USER_ACTION_MODIFY%>' href="javascript:splitLineItems();" onmouseover="window.status='Click here to split line items';return true" onmouseout="window.status='';return true">
                        Split Line Items</chiptrack:restrictedLink>
                    <% } %>

                    </td>
                </tr>
                <tr><td class="NArialL">&nbsp;</td></tr>
                 <%int noOfColumnsBeforeQty = 7;%>
	            <tr>
	                <td width="8%" align="center" bgcolor="#993333">
                        <font class="NArialL"><font color="#FFFFFF">Line Item</font></font>
                    </td>
                    <td width="8%" align="center" bgcolor="#993333">
                        <font class="NArialL"><font color="#FFFFFF">PO Line Item&nbsp;*</font></font>
                    </td>
	                <td width="18%" align="center" bgcolor="#993333">
                        <font class="NArialL"><font color="#FFFFFF"><bean:message key="label.mfgPartNumber" />&nbsp;*</font></font>
	                </td>
                    <% if(ConfigManager.getBooleanProperty(ConfigManager.PROP_SHOW_SALES_LINEITEM_MARKETING_PART_NUMBER)) { %>
                        <td width="18%" align="center" bgcolor="#993333" class="NArialL"><font color="#FFFFFF"><bean:message key="label.mktgPartNumber" /></font></td>
                     <% noOfColumnsBeforeQty ++; } %>
                    <td width="15%" align="center" bgcolor="#993333"><font class="NArialL">
                        <font color="#FFFFFF"><bean:message key="label.customerPartNumber"/></font></font>
                    </td>
                    <td width="15%" align="center" bgcolor="#993333">
						<font class="NArialL"><font color="#FFFFFF">Description</font></font>
					</td>
				    <td width='1%' align="center" bgcolor="#993333">
						<font class="NArialL"><font color="#FFFFFF">Taxable</font></font>
					</td>
					<td width="17%" align="center" bgcolor="#993333">
						<font class="NArialL"><font color="#FFFFFF">Req'd Dock Date<br>(mm/dd/yyyy)&nbsp;*</font></font>
					</td>
					<td width="5%" align="center" bgcolor="#993333">
						<font class="NArialL"><font color="#FFFFFF">Quantity&nbsp;*</font></font>
					</td>
					<td width="10%" align="center" bgcolor="#993333">
						<font class="NArialL"><font color="#FFFFFF">Price($) </font></font>
					</td>
					<td width="15%" align="center" bgcolor="#993333">
						<font class="NArialL"><font color="#FFFFFF">Amount</font></font>
					</td>
				    <td width="15%" align="center" bgcolor="#993333">
						<font class="NArialL"><font color="#FFFFFF">Zero Price</font></font>
					</td>
					<td width="10%" align='center' bgcolor='#993333'>
						<font class='NArialL'><font color="#FFFFFF">Cancel</font></font>
					</td>
					<td width="10%" align='center' bgcolor='#993333'>
						<font class='NArialL'><font color="#FFFFFF">Expedite<br>Fee</font></font>
					</td>
                    <%
                         if(ConfigManager.getBooleanProperty(ConfigManager.PROP_SHOW_SALES_LINEITEM_CUSTOM_PRICE_FIELD1)) {
                     %>
                        <td width="10%" align="center" bgcolor="#993333" class="NArialL"><font color="#FFFFFF"><bean:message key="label.sales.lineItem.customPriceField1" /></font></td>
                     <%
                         }
                         if(ConfigManager.getBooleanProperty(ConfigManager.PROP_SHOW_SALES_LINEITEM_CUSTOM_TEXT_FIELD1)) {
                     %>
                            <td width="10%" align="center" bgcolor="#993333" class="NArialL"><font color="#FFFFFF"><bean:message key="label.sales.lineItem.customTextField1" /></font></td>
                     <%
                         }
                     %>
                </tr>
                
                <jsp:include page="currentLineItemsForChangeSalesOrder.jsp" flush="true" >
                    <jsp:param name="noOfColumnsBeforeQty" value="<%=noOfColumnsBeforeQty%>"/>
                </jsp:include>
                <tr id="rowIndex"><td colspan='13' >&nbsp;<FONT id="font1"></FONT></TD></TR>
				<tr><td colspan='13' >&nbsp;</TD></TR>
				<tr>
					<td colspan="<%=noOfColumnsBeforeQty+2%>" align="right" bgcolor="#FFFFFF" class="NArialL">Total</td>
					<td width="15%" bgcolor="#FFFFFF">&nbsp;<html:text name="salesOrderForm" property="subTotalAsString" disabled="true" styleClass="valuetxfield" size="25"/></td>
					<td width="15%" align="center" bgcolor="#FFFFFF">&nbsp;</td>
					<td width="10%" align="center" bgcolor="#FFFFFF">&nbsp;</td>
					<td width="10%" align="center" bgcolor="#FFFFFF">&nbsp;</td>
				</tr>
				<%  int salesTaxStateColspan = noOfColumnsBeforeQty-3; %>
				<tr>
					<td colspan="<%=salesTaxStateColspan%>" class="NArialL" align=right>Sales Tax State</td>
					<td class="NArialL">
						<logic:equal parameter="isSample" value="0">
						<html:select name="salesOrderForm" property="salesTaxType" styleClass="txfield" disabled= "true">
							<html:option value="0">Non Taxable</html:option>
							<html:options collection="salesTaxes" property="value" labelProperty="label" />
						</html:select>
						</logic:equal>

						<logic:notEqual parameter="isSample" value="0">
						<html:select name="salesOrderForm" property="salesTaxType" styleClass="txfield" onchange="javascript:addNewSalesTaxType(this);">
						<html:option value="0" >Non Taxable</html:option>
						<html:options collection="salesTaxes" property="value" labelProperty="label" />
						<html:option value="-1">Others</html:option>
						</html:select>
						</logic:notEqual>
					</td>
					<td colspan=<%=noOfColumnsBeforeQty-salesTaxStateColspan+1%> align=right class="NArialL">Sales Tax</td>
					<td width="15%" class="NArialL" >&nbsp;&nbsp;<html:text name="salesOrderForm" property="salesTaxAsString" styleClass="valuetxfield"  size="25" disabled="true"/></td>
					<td width="15%" align="center" bgcolor="#FFFFFF">&nbsp;</td>
					<td width="10%" align="center" bgcolor="#FFFFFF">&nbsp;</td>
					<td width="10%" align="center" bgcolor="#FFFFFF">&nbsp;</td>
				</tr>
				<tr>
					<td colspan="<%=salesTaxStateColspan%>" align=right class="NArialL"><font class="NArialL"><FONT id="font-1"></FONT></font></td>
					<td class="NarialL" ><font class="NArialL"><FONT id="font-2"></FONT></font></td>
					<td colspan=<%=noOfColumnsBeforeQty-salesTaxStateColspan+1%> align=right class="NArialL">Freight</td>
					<td width="15%" class="NArialL">
						<logic:equal parameter="isSample" value="0">
						$<html:text name="salesOrderForm" property="frieghtAsDouble" styleClass="valuetxfield"  size="25" disabled="true" />
						</logic:equal>

						<logic:notEqual parameter="isSample" value="0">
						$<html:text name="salesOrderForm" property="frieghtAsDouble" styleClass="valuetxfield"  size="25" maxlength="9"  onkeypress="<%=restrictCharsJSFnc%>" onkeyup="<%=restrictAmtJSFnc%>" />
						</logic:notEqual>
					</td>
					<td width="15%" align="center" bgcolor="#FFFFFF">&nbsp;</td>
					<td width="10%" align="center" bgcolor="#FFFFFF">&nbsp;</td>
					<td width="10%" align="center" bgcolor="#FFFFFF">&nbsp;</td>
				</tr>
				<tr>
				    <td colspan="<%=salesTaxStateColspan%>" align=right class="NArialL"><font class="NArialL"><FONT id="font-3"></FONT></font></td>
				    <td class="NarialL" ><font class="NArialL"><FONT id="font-4"></FONT></font></td>
					<td colspan=<%=noOfColumnsBeforeQty-salesTaxStateColspan+1%> align=right class="NArialL"><html:text name="salesOrderForm" property="miscName" styleClass="valuetxfield" /></td>
					<td width="15%" class="NArialL">
						<logic:equal parameter="isSample" value="0">
						$<html:text name="salesOrderForm" property="miscAsDouble" styleClass="valuetxfield" size="25" disabled="true"/>
						</logic:equal>

						<logic:notEqual parameter="isSample" value="0">
						$<html:text name="salesOrderForm" property="miscAsDouble" styleClass="valuetxfield" size="25" maxlength="9"  onkeypress="javascript:restrictCharacters(this,7,3)" onkeyup="javascript:restrictAmt(this,7,3)" />
						</logic:notEqual>
					</td>
					<td width="15%" align="center" bgcolor="#FFFFFF">&nbsp;</td>
					<td width="10%" align="center" bgcolor="#FFFFFF">&nbsp;</td>
					<td width="10%" align="center" bgcolor="#FFFFFF">&nbsp;</td>
				</tr>
				<tr>
					<td colspan="<%=noOfColumnsBeforeQty+2%> " align=right class="NArialL">Order Total</td>
					<td width="15%" class="NArialL">&nbsp;&nbsp;<html:text name="salesOrderForm" property="orderTotalAsString" disabled="true" styleClass="valuetxfield" size="25"/></td>
					<td width="15%" align="center" bgcolor="#FFFFFF">&nbsp;</td>
					<td width="10%" align="center" bgcolor="#FFFFFF">&nbsp;</td>
					<td width="10%" align="center" bgcolor="#FFFFFF">&nbsp;</td>
				</tr>
				<tr><td colspan="13">&nbsp;</td></tr>
				<tr>
					<td colspan="<%=noOfColumnsBeforeQty+2%> ">&nbsp</td>
					<td align="center"><a href="javascript:addTextArea();"><img src="<%=chipTracContext%>/jsp/includes/images/addmore.gif" border=0 onmouseover="window.status='Click here to Add LineItem';return true" onmouseout="window.status='';return true" title="Click here to Add LineItem"></a></td>
					<td width="15%" align="center">
                        <% if((request.getParameter("isSample") != null) && (request.getParameter("isSample").equals("0"))) { %>
                                <chiptrack:restrictedLink functionality='<%=Functionality.SAMPLE_CHANGE_ORDER%>' action='<%=User.USER_ACTION_MODIFY%>' href="javascript:submitPage('UPDATE');" onmouseover="window.status='Click here to Calculate Order Total';return true" onmouseout="window.status='';return true">
                                <img src="<%=chipTracContext%>/jsp/includes/images/calculate.gif" border='0' title="Click here to calculate Order Total" ></chiptrack:restrictedLink>
                        <% } else { %>
                               <chiptrack:restrictedLink functionality='<%=Functionality.SALES_CHANGE_ORDER%>' action='<%=User.USER_ACTION_MODIFY%>' href="javascript:submitPage('UPDATE');" onmouseover="window.status='Click here to Calculate Order Total';return true" onmouseout="window.status='';return true">
                                <img src="<%=chipTracContext%>/jsp/includes/images/calculate.gif" border='0' title="Click here to calculate Order Total" ></chiptrack:restrictedLink>
                        <% } %>

					</td>
					<td width="15%" align="center" bgcolor="#FFFFFF">&nbsp;</td>
					<td width="10%" align="center" bgcolor="#FFFFFF">&nbsp;</td>
					<td width="10%" align="center" bgcolor="#FFFFFF">&nbsp;</td>
				</tr>
			</table>
		</td>
	</tr>
	<tr>
        <td colspan=6 align=center>
            <% if((request.getParameter("isSample") != null) && (request.getParameter("isSample").equals("0"))) { %>
                    <chiptrack:restrictedLink functionality='<%=Functionality.SAMPLE_CHANGE_ORDER %>' action='<%=User.USER_ACTION_MODIFY%>' href="javascript:submitPage('SUBMIT');" onmouseover="window.status='Click to save Changes to Sales Order';return true" onmouseout="window.status='';return true">
                    <img src="<%=chipTracContext%>/jsp/includes/images/submit.gif" border='0' title="Click here to Save Changes to Sales Order"></chiptrack:restrictedLink>
            <% } else { %>
                   <chiptrack:restrictedLink functionality='<%=Functionality.SALES_CHANGE_ORDER%>' action='<%=User.USER_ACTION_MODIFY%>' href="javascript:submitPage('SUBMIT');" onmouseover="window.status='Click to save Changes to Sales Order';return true" onmouseout="window.status='';return true">
                    <img src="<%=chipTracContext%>/jsp/includes/images/submit.gif" border='0' title="Click here to Save Changes to Sales Order"></chiptrack:restrictedLink>
            <% } %>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <a href="javascript:resetForm();" onmouseover="window.status='Click to Reset';return true" onmouseout="window.status='';return true" title="CLick here to Reset"><img src='<%=chipTracContext%>/jsp/includes/images/reset.gif' border=0></a>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <a href="<%=chipTracContext%>/changeOrders.do?isSample=<%=request.getParameter("isSample")%>" onmouseover="window.status='Click to Cancel Changes';return true" onmouseout="window.status='';return true" title="CLick here to Cancel Changes" ><img src="<%=chipTracContext%>/jsp/includes/images/cancel.gif" border='0'></a>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        </td>
    </tr>
</table>
<input type="hidden" name="customerName" value="<%=salesOrderForm.getCustomerName()%>" >
<input type="hidden" name="customerId" value="<%=salesOrderForm.getCustomerId()%>" >
<input type="hidden" name="salesOrderId" value="<%=salesOrderForm.getSalesOrderId()%>" >
<input type="hidden" name="changeNo" value="<%=salesOrderForm.getChangeNo()%>" >
<input type="hidden" name="isSample" value="<%=request.getParameter("isSample")%>" >
<input type="hidden" name="salesOrderNo" value="<%=salesOrderForm.getSalesOrderNo()%>" >
<input type="hidden" name="shippingMethodName" value="<%=salesOrderForm.getShippingMethodName() != null ? salesOrderForm.getShippingMethodName() : ""%>" >
<input type="hidden" name="action" value="">
<input type="hidden" name="selectedMethod" value="<%=selectedMethod%>">
<input type="hidden" name="selectedAccount" value="<%=selectedAccount%>">
<input type="hidden" name="shipAccount1" value="<%=request.getAttribute("Method")%>"/>
<input type="hidden" name="splitLineItems" value="no">
<input type="hidden" name="status" value="<%=salesOrderForm.getStatus() %>"/>
<input type="hidden" name="quotationId" value="<%=salesOrderForm.getQuotationId() %>"/>
</html:form>
</html:html>
<BR><BR><BR></TD>
<TD bgcolor="#ffffff"><IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=1></TD>
</TR>
</TABLE>
<!-- Footer starts here -->
<%@ include file="/jsp/includes/footer.jsp" %>
<!-- footer end here -->
<%
	if ( "false".equalsIgnoreCase( ( String ) request.getAttribute( "otherstateadded" ) ) )
	{
%>
	<script language="javascript">
		addNewSalesTaxType(document.salesOrderForm.salesTaxType);
		document.salesOrderForm.newSalesState.value = "<%=request.getAttribute("newsalesstate") %>"
		document.salesOrderForm.newSalesTax.value = "<%=request.getAttribute("newsalesvalue") %>"
	</script>
<% } %>
<script language="javascript">var noofrows = <%=noOfRows%>;</script>


</BODY>
</HTML>